Skip to content

Commit e3a0e5c

Browse files
authored
fixing random seed issue in pm.Model definition (#403)
* fixing random seed issue in pm.Model definition * re-run and saved with jupytext installed * re-run and updated spline.myst.md * pre-commit passing
1 parent c90e91e commit e3a0e5c

File tree

2 files changed

+285
-308
lines changed

2 files changed

+285
-308
lines changed

examples/case_studies/spline.ipynb

+281-306
Large diffs are not rendered by default.

myst_nbs/case_studies/spline.myst.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupytext:
66
format_version: 0.13
77
jupytext_version: 1.13.7
88
kernelspec:
9-
display_name: Python 3.10.4 ('pymc_env')
9+
display_name: Python 3 (ipykernel)
1010
language: python
1111
name: python3
1212
---
@@ -27,6 +27,8 @@ kernelspec:
2727
Often, the model we want to fit is not a perfect line between some $x$ and $y$.
2828
Instead, the parameters of the model are expected to vary over $x$.
2929
There are multiple ways to handle this situation, one of which is to fit a *spline*.
30+
Spline fit is effectively a sum of multiple individual curves (piecewise polynomials), each fit to a different section of $x$, that are tied together at their boundaries, often called *knots*.
31+
3032
The spline is effectively multiple individual lines, each fit to a different section of $x$, that are tied together at their boundaries, often called *knots*.
3133

3234
Below is a full working example of how to fit a spline using PyMC. The data and model are taken from [*Statistical Rethinking* 2e](https://xcelab.net/rm/statistical-rethinking/) by [Richard McElreath's](https://xcelab.net/rm/) {cite:p}`mcelreath2018statistical`.
@@ -158,7 +160,7 @@ Finally, the model can be built using PyMC. A graphical diagram shows the organi
158160

159161
```{code-cell} ipython3
160162
COORDS = {"splines": np.arange(B.shape[1])}
161-
with pm.Model(coords=COORDS, rng_seeder=RANDOM_SEED) as spline_model:
163+
with pm.Model(coords=COORDS) as spline_model:
162164
a = pm.Normal("a", 100, 5)
163165
w = pm.Normal("w", mu=0, sigma=3, size=B.shape[1], dims="splines")
164166
mu = pm.Deterministic("mu", a + pm.math.dot(np.asarray(B, order="F"), w.T))

0 commit comments

Comments
 (0)