Kernel: base
Perform one sample Bayesian t-test on some toy data. Code is from
https://github.com/bambinos/bambi/blob/main/docs/notebooks/t-test.ipynb
In [1]:
In [9]:
Out[9]:
/opt/anaconda3/lib/python3.8/site-packages/probml_utils/plotting.py:25: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [2]:
Out[2]:
WARNING (pytensor.configdefaults): g++ not detected! PyTensor will be unable to compile C-implementations and will default to Python. Performance may be severely degraded. To remove this warning, set PyTensor flags cxx to an empty string.
<frozen importlib._bootstrap>:219: RuntimeWarning: scipy._lib.messagestream.MessageStream size changed, may indicate binary incompatibility. Expected 56 from C header, got 64 from PyObject
WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
In [26]:
In [4]:
In [6]:
Out[6]:
In [11]:
Out[11]:
/opt/anaconda3/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/violinplot.py:64: UserWarning: This figure was using a layout engine that is incompatible with subplots_adjust and/or tight_layout; not calling subplots_adjust.
fig.subplots_adjust(wspace=0)
saving image to /Users/kpmurphy/github/bookv2/figures/ttest_bambi_violin.pdf
Figure size: [13.8 4.6]
In [25]:
Out[25]:
0 4.773791
1 5.063908
2 0.006240
3 9.852575
4 6.157711
...
155 9.893494
156 4.516609
157 5.574279
158 10.181567
159 4.648000
Name: Val, Length: 160, dtype: float64
In [28]:
Out[28]:
saving image to /Users/kpmurphy/github/bookv2/figures/ttest_bambi_boxplot.pdf
Figure size: [6. 4.]
In [12]:
Out[12]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [Group, Val_sigma]
Sampling 4 chains for 1_000 tune and 1_000 draw iterations (4_000 + 4_000 draws total) took 57 seconds.
In [13]:
Out[13]:
Formula: Val ~ 0 + Group
Family name: Gaussian
Link: identity
Observations: 280
Priors:
Common-level effects
Group ~ Normal(mu: [0. 0.], sigma: [11.6292 11.6292])
Auxiliary parameters
sigma ~ HalfStudentT(nu: 4, sigma: 2.302)
------
* To see a plot of the priors call the .plot_priors() method.
* To see a summary or plot of the posterior pass the object returned by .fit() to az.summary() or az.plot_trace()
In [14]:
Out[14]:
In [19]:
Out[19]:
saving image to /Users/kpmurphy/github/bookv2/figures/ttest_bambi_post_diff.pdf
Figure size: [6. 4.]
In [20]:
Out[20]:
saving image to /Users/kpmurphy/github/bookv2/figures/ttest_bambi_post_a.pdf
Figure size: [6. 4.]
saving image to /Users/kpmurphy/github/bookv2/figures/ttest_bambi_post_b.pdf
Figure size: [6. 4.]