# How to set a seed for pm.sample?

**URL:** <https://discourse.pymc.io/t/how-to-set-a-seed-for-pm-sample/11497>\
**Category:** v5\
**Tags:** modeling\
**Created:** [February 28, 2023, 1:19pm UTC](https://discourse.pymc.io/t/how-to-set-a-seed-for-pm-sample/11497 "2023-02-28T13:19:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [February 28, 2023, 2:19pm UTC](https://discourse.pymc.io/t/how-to-set-a-seed-for-pm-sample/11497/2 "2023-02-28T14:19:16Z")

</div>

You should use `sample(random_seed=x)`. The best is to pass a numpy Generator, like:

```python
rng = np.random.default_rng(666)
...
  pm.sample(random_seed=rng)
  pm.sample_prior_predictive(random_seed=rng)
  pm.sample_posterior_predictive(..., random_seed=rng)

```

Global seed is ignored. Multiple seeds per chain as with [666, 666, 666, 666], uses each number for each chain. It doesn’t make much sense to pass the same values, because you don’t want your chains to be identical. And since you want multiple values you can just pass `rng` and PyMC will draw 4 values for you.

---

_[View the full topic](https://discourse.pymc.io/t/how-to-set-a-seed-for-pm-sample/11497)._
