pymc.draw — PyMC 5.22.0 documentation (original) (raw)

pymc.draw(vars, draws=1, random_seed=None, **kwargs)[source]#

Draw samples for one variable or a list of variables.

Parameters:

varsTensorVariable or iterable of TensorVariable

A variable or a list of variables for which to draw samples.

drawsint, default 1

Number of samples needed to draw.

random_seedint, RandomState or Generator, optional

Seed for the random number generator.

**kwargsdict, optional

Keyword arguments for pymc.pytensorf.compile_pymc().

Returns:

list of ndarray

A list of numpy arrays.

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)