Skip to content

Commit

Permalink
Changed so that all steppers and the samplers use random scans.
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmusab committed Dec 30, 2015
1 parent 842cf7d commit 5bf3fb7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mcmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@
Stepper.call(this, params, state, log_post);
this.param_names = Object.keys(this.params);
this.substeppers = [];
this.stepper_indices = [];
for(var i = 0; i < this.param_names.length; i++) {
var param = params[this.param_names[i]];
var SelectStepper;
Expand Down Expand Up @@ -855,17 +854,16 @@
param_options.target_accept_rate = param_options.target_accept_rate || options.target_accept_rate;
param_options.is_adapting = param_options.is_adapting || options.is_adapting;
this.substeppers[i] = new SelectStepper(param_object_wrap, state, log_post, param_options);
this.stepper_indices[i] = i;
}
};

AmwgStepper.prototype = Object.create(Stepper.prototype);
AmwgStepper.prototype.constructor = AmwgStepper;

AmwgStepper.prototype.step = function() {
shuffle_array(this.stepper_indices);
for(var i = 0; i < this.stepper_indices.length; i++) {
this.substeppers[this.stepper_indices[i]].step();
shuffle_array(this.substeppers);
for(var i = 0; i < this.substeppers.length; i++) {
this.substeppers[i].step();
}
return this.state;
};
Expand Down Expand Up @@ -962,6 +960,7 @@
* but also modifies the state in place.
*/
Sampler.prototype.step = function() {
shuffle_array(this.steppers);
for(var i = 0; i < this.steppers.length; i++) {
this.steppers[i].step();
}
Expand Down

0 comments on commit 5bf3fb7

Please sign in to comment.