pymc.draw#
- pymc.draw(vars, draws=1, random_seed=None, **kwargs)[源代码]#
为一个变量或变量列表绘制样本
- 参数:
- vars :
TensorVariable
或 iterable 的TensorVariable
TensorVariable 或 python:iterable 的 TensorVariable 要为其绘制样本的变量或变量列表。
- 抽取 :
int
, 默认值 1python:int, 默认值为 1 需要抽取的样本数量。
- random_seedpython:int, RandomState 或 Generator, 可选
随机数生成器的种子。
- **kwargs :
dict
, 可选python:dict, 可选 用于
pymc.pytensorf.compile_pymc()
的关键字参数。
- vars :
- 返回:
示例
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)