pymc.iter_sample(draws, step, start, trace=None, chain=0, tune=0, model=None, random_seed=None, callback=None)[source]#

Generate a trace on each iteration using the given step method.

Multiple step methods ared supported via compound step methods. Returns the amount of time taken.


The number of samples to draw


Step function


Starting point in parameter space (or partial point).

tracebackend or list

This should be a backend instance, or a list of variables to track. If None or a list of variables, the NDArray backend is used.

chainint, optional

Chain number used to store sample in backend. If cores is greater than one, chain numbers will start here.

tuneint, optional

Number of iterations to tune (defaults to 0).

modelModel (optional if in with context)
random_seedsingle random seed, optional

A function which gets called for every sample from the trace of a chain. The function is called with the trace and the current draw and will contain all samples for a single trace. the draw.chain argument can be used to determine which of the active chains the sample is drawn from. Sampling can be interrupted by throwing a KeyboardInterrupt in the callback.


Contains all samples up to the current iteration


for trace in iter_sample(500, step):