Multivariate normal distribution.
\[f(x \mid \pi, T) = \frac{|T|^{1/2}}{(2\pi)^{k/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime} T (x-\mu) \right\}\]
float
Vector of means.
float
, optional
Covariance matrix. Exactly one of cov, tau, or chol is needed.
float
, optional
Precision matrix. Exactly one of cov, tau, or chol is needed.
float
, optional
Cholesky decomposition of covariance matrix. Exactly one of cov, tau, or chol is needed.
Whether chol is the lower tridiagonal cholesky factor.
Examples
Define a multivariate normal variable for a given covariance matrix:
cov = np.array([[1.0, 0.5], [0.5, 2]]) mu = np.zeros(2) vals = pm.MvNormal("vals", mu=mu, cov=cov, shape=(5, 2))
Most of the time it is preferable to specify the cholesky factor of the covariance instead. For example, we could fit a multivariate outcome like this (see the docstring of LKJCholeskyCov for more information about this):
mu = np.zeros(3) true_cov = np.array( [ [1.0, 0.5, 0.1], [0.5, 2.0, 0.2], [0.1, 0.2, 1.0], ], ) data = np.random.multivariate_normal(mu, true_cov, 10) sd_dist = pm.Exponential.dist(1.0, shape=3) chol, corr, stds = pm.LKJCholeskyCov( "chol_cov", n=3, eta=2, sd_dist=sd_dist, compute_corr=True ) vals = pm.MvNormal("vals", mu=mu, chol=chol, observed=data)
For unobserved values it can be better to use a non-centered parametrization:
sd_dist = pm.Exponential.dist(1.0, shape=3) chol, _, _ = pm.LKJCholeskyCov("chol_cov", n=3, eta=2, sd_dist=sd_dist, compute_corr=True) vals_raw = pm.Normal("vals_raw", mu=0, sigma=1, shape=(5, 3)) vals = pm.Deterministic("vals", pt.dot(chol, vals_raw.T).T)
Methods
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4