Skip to content

Commit 5344de9

Browse files
committed
fix pre-commit
1 parent 9394bb8 commit 5344de9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

examples/time_series/Time_Series_Generative_Graph.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,7 @@
798798
"\n",
799799
"ax[-1].set_xlabel(\"time\")\n",
800800
"\n",
801-
"fig.suptitle(\n",
802-
" \"AR(2) Posterior Predictive Samples\", fontsize=18, fontweight=\"bold\", y=1.05\n",
803-
");"
801+
"fig.suptitle(\"AR(2) Posterior Predictive Samples\", fontsize=18, fontweight=\"bold\", y=1.05);"
804802
]
805803
},
806804
{

examples/time_series/Time_Series_Generative_Graph.myst.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ with pm.Model(coords=coords, check_bounds=False) as model:
131131
rho = pm.Normal(name="rho", mu=0, sigma=0.2, dims=("lags",))
132132
sigma = pm.HalfNormal(name="sigma", sigma=0.2)
133133
134-
ar_init_obs = pm.MutableData(name="ar_init_obs", value=np.zeros(lags), dims=("lags",))
134+
ar_init_obs = pm.Data(name="ar_init_obs", value=np.zeros(lags), dims=("lags",))
135135
ar_init = pm.Normal(name="ar_init", observed=ar_init_obs, dims=("lags",))
136136
137-
ar_innov_obs = pm.MutableData("ar_innov_obs", np.zeros(trials - lags), dims=("steps",))
137+
ar_innov_obs = pm.Data("ar_innov_obs", np.zeros(trials - lags), dims=("steps",))
138138
ar_innov = pm.CustomDist(
139139
"ar_dist",
140140
ar_init,
@@ -179,7 +179,7 @@ for i, hdi_prob in enumerate((0.94, 0.64), 1):
179179
ax.plot(prior.prior["ar"].mean(("chain", "draw")), color="C0", label="Mean")
180180
ax.legend(loc="upper right")
181181
ax.set_xlabel("time")
182-
ax.set_title("AR(2) Prior Samples", fontsize=18, fontweight="bold")
182+
ax.set_title("AR(2) Prior Samples", fontsize=18, fontweight="bold");
183183
```
184184

185185
It is not surprising that the prior distribution is a stationary process around zero given that the prior of the `rho` parameter is far from one.
@@ -197,7 +197,7 @@ for i, axi in enumerate(ax, start=chosen_draw):
197197
color="C0" if i == chosen_draw else "black",
198198
)
199199
axi.set_title(f"Sample {i}", fontsize=18, fontweight="bold")
200-
ax[-1].set_xlabel("time")
200+
ax[-1].set_xlabel("time");
201201
```
202202

203203
## Posterior
@@ -239,14 +239,14 @@ axes = az.plot_trace(
239239
],
240240
backend_kwargs={"figsize": (12, 5), "layout": "constrained"},
241241
)
242-
plt.gcf().suptitle("AR(2) Model Trace", fontsize=18, fontweight="bold")
242+
plt.gcf().suptitle("AR(2) Model Trace", fontsize=18, fontweight="bold");
243243
```
244244

245245
```{code-cell} ipython3
246246
axes = az.plot_posterior(
247247
trace, var_names=["rho", "sigma"], ref_val=[*rho_true, sigma_true], figsize=(15, 5)
248248
)
249-
plt.gcf().suptitle("AR(2) Model Parameters Posterior", fontsize=18, fontweight="bold")
249+
plt.gcf().suptitle("AR(2) Model Parameters Posterior", fontsize=18, fontweight="bold");
250250
```
251251

252252
We see we have successfully recovered the true parameters of the model.
@@ -282,7 +282,7 @@ ax.plot(prior.prior["ar"].mean(("chain", "draw")), color="C0", label="Mean")
282282
ax.plot(ar_obs, color="black", label="Observed")
283283
ax.legend(loc="upper right")
284284
ax.set_xlabel("time")
285-
ax.set_title("AR(2) Posterior Predictive Samples", fontsize=18, fontweight="bold")
285+
ax.set_title("AR(2) Posterior Predictive Samples", fontsize=18, fontweight="bold");
286286
```
287287

288288
Overall, we the model is capturing the global dynamics of the time series. In order to have a abetter insight of the model, we can plot a subset of the posterior samples and compare them with the observed data.
@@ -299,7 +299,7 @@ for i, axi in enumerate(ax):
299299
300300
ax[-1].set_xlabel("time")
301301
302-
fig.suptitle("AR(2) Posterior Predictive Samples", fontsize=18, fontweight="bold", y=1.05)
302+
fig.suptitle("AR(2) Posterior Predictive Samples", fontsize=18, fontweight="bold", y=1.05);
303303
```
304304

305305
## Authors

0 commit comments

Comments
 (0)