pymc.draw#
- pymc.draw(vars, draws=1, random_seed=None, **kwargs)[source]#
Draw samples for one variable or a list of variables
- Parameters:
- vars
TensorVariable
or iterable ofTensorVariable
A variable or a list of variables for which to draw samples.
- draws
int
, default 1 Number of samples needed to draw.
- random_seed
int
,RandomState
orGenerator
, optional Seed for the random number generator.
- **kwargs
dict
, optional Keyword arguments for
pymc.pytensorf.compile_pymc()
.
- vars
- Returns:
Examples
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[0].shape == (num_draws,) assert draws[1].shape == (num_draws, 10) assert draws[2].shape == (num_draws, 5)