- pymc.draw(vars, draws=1, random_seed=None, **kwargs)[source]#
Draw samples for one variable or a list of variables
TensorVariableor iterable of
A variable or a list of variables for which to draw samples.
int, default 1
Number of samples needed to draw.
Seed for the random number generator.
Keyword arguments for
import pymc as pm # Draw samples for one variable with pm.Model(): x = pm.Normal("x") x_draws = pm.draw(x, draws=100) print(x_draws.shape) # Draw 1000 samples for several variables with pm.Model(): x = pm.Normal("x") y = pm.Normal("y", shape=10) z = pm.Uniform("z", shape=5) num_draws = 1000 # Draw samples of a list variables draws = pm.draw([x, y, z], draws=num_draws) assert draws.shape == (num_draws,) assert draws.shape == (num_draws, 10) assert draws.shape == (num_draws, 5)