-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from ColCarroll/more_examples
More examples
- Loading branch information
Showing
9 changed files
with
150 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Forest Plot | ||
=========== | ||
_thumb: .5, .8 | ||
""" | ||
import arviz as az | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
trace = az.load_trace('data/centered_eight_trace.gzip') | ||
az.forestplot(trace, varnames=('theta__0', 'theta__1', 'theta__2')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Joint Plot | ||
========== | ||
_thumb: .5, .8 | ||
""" | ||
import arviz as az | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
trace = az.load_trace('data/non_centered_eight_trace.gzip') | ||
az.jointplot(trace, kind='hexbin', varnames=('tau', 'mu')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
KDE Plot | ||
======== | ||
_thumb: .2, .8 | ||
""" | ||
import arviz as az | ||
import matplotlib.pyplot as plt | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
trace = az.load_trace('data/non_centered_eight_trace.gzip') | ||
|
||
fig, ax = plt.subplots(figsize=(12, 8)) | ||
az.kdeplot(trace.tau, fill_alpha=0.1, ax=ax) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Pair Plot | ||
========= | ||
_thumb: .2, .5 | ||
""" | ||
import arviz as az | ||
import numpy as np | ||
import pymc3 as pm | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
# Data of the Eight Schools Model | ||
J = 8 | ||
y = np.array([28., 8., -3., 7., -1., 1., 18., 12.]) | ||
sigma = np.array([15., 10., 16., 11., 9., 11., 10., 18.]) | ||
|
||
|
||
with pm.Model() as centered_eight: | ||
mu = pm.Normal('mu', mu=0, sd=5) | ||
tau = pm.HalfCauchy('tau', beta=5) | ||
theta = pm.Normal('theta', mu=mu, sd=tau, shape=J) | ||
obs = pm.Normal('obs', mu=theta, sd=sigma, observed=y) | ||
centered_eight_trace = pm.sample() | ||
|
||
az.pairplot(centered_eight_trace, | ||
varnames=['theta__0', 'theta__1', 'tau', 'mu'], | ||
divergences=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Parallel Plot | ||
============= | ||
_thumb: .2, .5 | ||
""" | ||
import arviz as az | ||
import numpy as np | ||
import pymc3 as pm | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
# Data of the Eight Schools Model | ||
J = 8 | ||
y = np.array([28., 8., -3., 7., -1., 1., 18., 12.]) | ||
sigma = np.array([15., 10., 16., 11., 9., 11., 10., 18.]) | ||
|
||
|
||
with pm.Model() as centered_eight: | ||
mu = pm.Normal('mu', mu=0, sd=5) | ||
tau = pm.HalfCauchy('tau', beta=5) | ||
theta = pm.Normal('theta', mu=mu, sd=tau, shape=J) | ||
obs = pm.Normal('obs', mu=theta, sd=sigma, observed=y) | ||
centered_eight_trace = pm.sample() | ||
|
||
az.parallelplot(centered_eight_trace, varnames=['theta', 'tau', 'mu']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Posterior Plot | ||
============== | ||
_thumb: .5, .8 | ||
""" | ||
import arviz as az | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
trace = az.load_trace('data/non_centered_eight_trace.gzip') | ||
az.posteriorplot(trace, varnames=['theta__0', 'theta__1', 'tau', 'mu']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Posterior Predictive Check Plot | ||
=============================== | ||
_thumb: .6, .5 | ||
""" | ||
import arviz as az | ||
import numpy as np | ||
import pymc3 as pm | ||
|
||
az.style.use('arviz-darkgrid') | ||
|
||
# Data of the Eight Schools Model | ||
J = 8 | ||
y = np.array([28., 8., -3., 7., -1., 1., 18., 12.]) | ||
sigma = np.array([15., 10., 16., 11., 9., 11., 10., 18.]) | ||
|
||
|
||
with pm.Model() as centered_eight: | ||
mu = pm.Normal('mu', mu=0, sd=5) | ||
tau = pm.HalfCauchy('tau', beta=5) | ||
theta = pm.Normal('theta', mu=mu, sd=tau, shape=J) | ||
obs = pm.Normal('obs', mu=theta, sd=sigma, observed=y) | ||
centered_eight_trace = pm.sample() | ||
|
||
with centered_eight: | ||
ppc_samples = pm.sample_ppc(centered_eight_trace) | ||
|
||
az.ppcplot(y, ppc_samples) |