How to force Python emcee to move sampler with a certain step

128 Views Asked by At

I run emcee sampler like:

p0 = sampler.run_mcmc(p0, conf_res['niter_burn'], progress=True)

Where p0 is a list of starting values for each variable parameter

p0 = [
        np.array([randrange_float(var['min_val'], var['max_val'], var['step']) for var in 
        conf_res['var_params_list']]) for i in range(nwalkers)
    ]

It is calculating with randrange_float func:

def randrange_float(start, stop, step):
    """
    usage:
        randrange_float(2.1, 4.2, 0.3) # returns 2.4
    Args:
        start: min value
        stop: max value
        step: step size
    Return:
        float: random in the given range of values
    """
    return random.randint(0, int((stop - start) / step)) * step + start

Everything works fine, my starting parameters are without float part (except first one) because my step is 1.0.

Starting Values of Parameters:
#      P      P_phase      P_pr     Pr_phase    Pr_angle 
     40.83      91.00    2720.00     336.00      -6.00
     40.84     222.00    1940.00      35.00       1.00
     40.44     270.00    2540.00     242.00     -13.00
     40.83     145.00    2450.00      59.00      -5.00
     40.46     251.00    2330.00     106.00       8.00
.... nwalker times...

But when emcee sampler moved away from starting values (p0), I got parameters with float step. Is there a way to defile the step for emcee walker?
emcee.EnsembleSampler has moves parameter. Do I have to write my version of Move class? I can't understand what Mover class should return.

0

There are 0 best solutions below