pymc.iter_sample#

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.

Parameters
drawsint

The number of samples to draw

stepfunction

Step function

startdict

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.

tuneint, optional

Number of iterations to tune (defaults to 0).

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

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.

Yields
traceMultiTrace

Contains all samples up to the current iteration

Examples

for trace in iter_sample(500, step):
    ...