Skip to content

Commit 79d24fa

Browse files
Jonathan DekermanjianJonathan Dekermanjian
authored andcommitted
added rng to samplers
1 parent 2ce788f commit 79d24fa

File tree

2 files changed

+94
-92
lines changed

2 files changed

+94
-92
lines changed

examples/survival_analysis/weibull_aft.ipynb

Lines changed: 88 additions & 87 deletions
Large diffs are not rendered by default.

examples/survival_analysis/weibull_aft.myst.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ import statsmodels.api as sm
4242

4343
```{code-cell} ipython3
4444
%config InlineBackend.figure_format = 'retina'
45-
RANDOM_SEED = 8927
46-
np.random.seed(RANDOM_SEED)
45+
# Set a seed for reproducibility of results
46+
seed: int = sum(map(ord, "aft_weibull"))
47+
rng: np.random.Generator = np.random.default_rng(seed=seed)
4748
az.style.use("arviz-darkgrid")
4849
```
4950

@@ -117,7 +118,7 @@ with pm.Model() as model_1:
117118

118119
```{code-cell} ipython3
119120
with model_1:
120-
idata_param1 = pm.sample(nuts_sampler="numpyro")
121+
idata_param1 = pm.sample(nuts_sampler="numpyro", random_seed=rng)
121122
```
122123

123124
```{code-cell} ipython3
@@ -147,7 +148,7 @@ with pm.Model() as model_2:
147148

148149
```{code-cell} ipython3
149150
with model_2:
150-
idata_param2 = pm.sample(nuts_sampler="numpyro")
151+
idata_param2 = pm.sample(nuts_sampler="numpyro", random_seed=rng)
151152
```
152153

153154
```{code-cell} ipython3
@@ -182,7 +183,7 @@ with pm.Model() as model_3:
182183

183184
```{code-cell} ipython3
184185
with model_3:
185-
idata_param3 = pm.sample(tune=4000, draws=2000, nuts_sampler="numpyro")
186+
idata_param3 = pm.sample(tune=4000, draws=2000, nuts_sampler="numpyro", random_seed=rng)
186187
```
187188

188189
```{code-cell} ipython3

0 commit comments

Comments
 (0)