Skip to content

Commit d4dd3dd

Browse files
zaxtaxtwiecki
authored andcommitted
WIP: Update LKJ notebook to not refer to Wishart (#2184)
* Remove mentions of Wishart distribution in LKJ notebook. Change capitalization Change capitalization * Nudge users away from Wishart to the LKJ distribution in the doc string
1 parent 609974c commit d4dd3dd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

docs/source/notebooks/LKJ.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
"cell_type": "markdown",
1414
"metadata": {},
1515
"source": [
16-
"Outside of the [beta](https://en.wikipedia.org/wiki/Beta_distribution)-[binomial](https://en.wikipedia.org/wiki/Binomial_distribution) model, the multivariate normal model is likely the most studied Bayesian model in history. Unfortunately, as this [issue](https://github.com/pymc-devs/pymc3/issues/538) shows, `pymc3` cannot (yet) sample from the standard conjugate [normal-Wishart](https://en.wikipedia.org/wiki/Normal-Wishart_distribution) model. Fortunately, `pymc3` *does* support sampling from the [LKJ distribution](http://www.sciencedirect.com/science/article/pii/S0047259X09000876). This post will show how to fit a simple multivariate normal model using `pymc3` with an normal-LKJ prior.\n",
17-
"\n",
18-
"The normal-Wishart prior is conjugate for the multivariate normal model, so we can find the posterior distribution in closed form. Even with this closed form solution, sampling from a multivariate normal model in `pymc3` is important as a building block for more complex models.\n",
16+
"Outside of the [beta](https://en.wikipedia.org/wiki/Beta_distribution)-[binomial](https://en.wikipedia.org/wiki/Binomial_distribution) model, the multivariate normal model is likely the most studied Bayesian model in history. `PyMC3` supports sampling from the [LKJ distribution](http://www.sciencedirect.com/science/article/pii/S0047259X09000876). The LKJ distribution represents the distribution on correlation matrices and is conjugate to the multivariate normal distribution. This post will show how to fit a simple multivariate normal model using `pymc3` with a normal-LKJ prior.\n",
1917
"\n",
2018
"First, we generate some two-dimensional sample data."
2119
]

pymc3/distributions/multivariate.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,17 @@ class Wishart(Continuous):
542542
Note
543543
----
544544
This distribution is unusable in a PyMC3 model. You should instead
545-
use WishartBartlett or LKJCholeskyCov, LKJCorr.
545+
use LKJCholeskyCov or LKJCorr.
546546
"""
547547

548548
def __init__(self, nu, V, *args, **kwargs):
549549
super(Wishart, self).__init__(*args, **kwargs)
550550
warnings.warn('The Wishart distribution can currently not be used '
551551
'for MCMC sampling. The probability of sampling a '
552552
'symmetric matrix is basically zero. Instead, please '
553-
'use WishartBartlett or better yet, LKJCholeskyCov/LKJCorr.'
554-
'For more information on the issues surrounding the '
555-
'Wishart see here: https://github.com/pymc-devs/pymc3/issues/538.',
553+
'use LKJCholeskyCov or LKJCorr. For more information '
554+
'on the issues surrounding the Wishart see here: '
555+
'https://github.com/pymc-devs/pymc3/issues/538.',
556556
UserWarning)
557557
self.nu = nu
558558
self.p = p = V.shape[0]
@@ -624,6 +624,9 @@ def WishartBartlett(name, S, nu, is_cholesky=False, return_cholesky=False, testv
624624
This is not a standard Distribution class but follows a similar
625625
interface. Besides the Wishart distribution, it will add RVs
626626
c and z to your model which make up the matrix.
627+
628+
This distribution is usually a bad idea to use as a prior for multivariate
629+
normal. You should instead use LKJCholeskyCov or LKJCorr.
627630
"""
628631

629632
L = S if is_cholesky else scipy.linalg.cholesky(S)

0 commit comments

Comments
 (0)