Commit 44514cf9 authored by Jakob Stierhof's avatar Jakob Stierhof

Update help for uniform init & sanitize logic

The reduced "square" of parameter ranges given by
width is moved such that the center of the smaller
"square" is, if possible, placed at the current
parameter values. If this causes the "square" to
reach outside of the parameter ranges, the maximum
shift still inside is used.
parent 22d4abf9
Pipeline #6488 passed with stages
in 42 seconds
......@@ -891,6 +891,9 @@ EmceeFileRegister["par"] = &emceeFilePar;
% Available methods:
% uniform : Draw initial walker positions from a uniform distribution
% within the parameter ranges.
% ; width : [=1.0] Sub range used for initialization (must be <= 1).
% The initiale cube center coincides as much as
% possible with the current parameter values.
%
% gauss : Draw initial walker positions from a gaussian distribution
% within parameter ranges.
......@@ -987,18 +990,24 @@ private define emceeInitUniformPick (init, engine) %{{{
variable file = engine.leader.inFile;
variable par = __parameters(engine.fit.object);
variable numParameter = length(par.value);
variable want_t, max_t,t; % calculate where we want to move a smaller
% box, and how much we can shift it at most
if (file.mode & EMCEE_FILE_RANGE)
(feed, ) = file.read(engine, engine.totalNumberWalkers);
else
feed = @par;
want_t = par.value-init.width*0.5*(par.max-par.min)+par.min;
max_t = (1-init.width)*(par.max-par.min)+par.min;
t = _max(_min(want_t, max_t), 0.0);
(p,c) = __emcee_params(par, feed, engine.totalNumberWalkers);
k = 0;
_for i (0, length(c)-1) {
_for j (0, c[i]-1)
engine.walkers[j+k] = _max(p[i].min, _min(p[i].max, rand_uniform(numParameter)*init.width*(p[i].max-p[i].min)+p[i].min));
engine.walkers[j+k] = _max(p[i].min, _min(p[i].max, rand_uniform(numParameter)*init.width*(p[i].max-p[i].min)+t[i]));
k += c[i];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment