Skip to content

Commit

Permalink
Merge pull request #222 from null-a/fix-incrementalmh-just-sample
Browse files Browse the repository at this point in the history
Fix IncrementalMH justSample option
  • Loading branch information
stuhlmueller committed Sep 30, 2015
2 parents 5ff3a19 + dd6d6b7 commit 8896c0a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/inference/incrementalmh.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,14 @@ module.exports = function(env) {
}
}
} else {
var dist;
if (this.returnHist)
dist = erp.makeMarginalERP(util.logHist(this.returnHist));
else
dist = erp.makeMarginalERP({});
var hist;
if (this.returnSamps || this.onlyMAP) {
hist = {};
hist[JSON.stringify(this.MAP.value)] = { prob: 1, val: this.MAP.value };
} else {
hist = this.returnHist;
}
var dist = erp.makeMarginalERP(util.logHist(hist));
if (this.returnSamps) {
if (this.onlyMAP)
this.returnSamps.push(this.MAP);
Expand Down
43 changes: 42 additions & 1 deletion tests/test-inference.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,33 @@ var tests = [
cache: true,
store: { hist: { tol: 0 }, args: [100] },
geometric: true,
gaussianMean: { mean: { tol: 0.3 }, std: { tol: 0.3 }, args: [100000, 20000] },
gaussianMean: { mean: { tol: 0.3 }, std: { tol: 0.3 }, args: [100000] },
withCaching: true,
optionalErpParams: true,
variableSupport: true,
query: true
}
},
{
name: 'IMHjustSample',
func: 'IncrementalMH',
settings: {
args: [100, { justSample: true }]
},
models: {
deterministic: { hist: { tol: 0 } }
}
},
{
name: 'IMHonlyMAP',
func: 'IncrementalMH',
settings: {
args: [100, { onlyMAP: true }]
},
models: {
deterministic: { hist: { tol: 0 } }
}
},
{
name: 'PMCMC',
settings: {
Expand Down Expand Up @@ -239,7 +259,28 @@ var tests = [
variableSupport: true,
query: true
}
},
{
name: 'MHonlyMAP',
func: 'MCMC',
settings: {
args: { samples: 100, onlyMAP: true }
},
models: {
deterministic: { hist: { tol: 0 } }
}
},
{
name: 'MHjustSample',
func: 'MCMC',
settings: {
args: { samples: 100, justSample: true }
},
models: {
deterministic: { hist: { tol: 0 } }
}
}

];

var wpplRunInference = function(modelName, testDef) {
Expand Down

0 comments on commit 8896c0a

Please sign in to comment.