API

class multinorm.MultiNorm(mean=None, cov=None, names=None)[source]

Multivariate normal distribution.

Given n parameters, the mean and names should be one-dimensional with size n, and cov should be a two-dimensional matrix of shape (n, n).

See the documentation.

Parameters:
  • mean (numpy.ndarray) – Mean vector
  • cov (numpy.ndarray) – Covariance matrix
  • names (list) – Python list of parameter names (str). Default: use “par_i” with i = 0 .. N - 1.
conditional(pars)[source]

Conditional MultiNormal distribution.

See Conditional distribution.

TODO: document.

correlation

Correlation matrix (numpy.ndarray).

Correlation \(C\) is related to covariance \(\Sigma\) via:

\[C_{ij} = \frac{ \Sigma_{ij} }{ \sqrt{\Sigma_{ii} \Sigma_{jj}} }\]
cov

Covariance matrix (numpy.ndarray).

err

Error vector (numpy.ndarray).

Defined as \(\sigma_i = \sqrt{\Sigma_{ii}}\).

classmethod from_err(mean=None, err=None, names=None)[source]

Create MultiNorm from parameter errors.

With errors \(\sigma_i\) this will create a diagonal covariance matrix with

\[\Sigma_{ii} = \sigma_i^2\]
classmethod from_points(points, names=None)[source]

Create MultiNorm from parameter points.

Usually the points are samples from some distribution and creating this MultiNorm distribution is an estimate / approximation of that distribution of interest.

See: From points.

Parameters:points (numpy.ndarray) – Array of data points with shape (n, 2).
classmethod joint(distributions)[source]

Create joint MultiNorm distribution.

See Combine .

Parameters:distributions (list) – Python list of MultiNorm distributions.
Returns:MultiNorm – Combined joint distribution
marginal(pars)[source]

Marginal MultiNormal distribution.

See Marginal distribution.

Parameters:pars (list) – List of parameters (integer indices)
Returns:MultiNorm – Marginal distribution
mean

Mean vector (numpy.ndarray).

n

Number of dimensions of the distribution (int).

Given by the number of parameters.

names

Parameter names (list of str).

precision

Precision matrix (numpy.ndarray).

The inverse of the covariance matrix.

Sometimes called the “information matrix” or “Hesse matrix”.

sigma_distance(point)[source]

Number of standard deviations from the mean (float).

Also called the Mahalanobis distance. See Sigmas.

to_matplotlib_ellipse(n_sigma=1, **kwargs)[source]

Create matplotlib.patches.Ellipse.

See examples in Plot.

Parameters:n_sigma (int) – Number of standard deviations. See Sigmas.
to_mcerp()[source]

Convert to mcerp objects.

TODO: document

to_scipy()[source]

Convert to scipy.stats.multivariate_normal object.

The returned object is a “frozen” distribution object, with mean and covar set. It offers methods for pdf, logpdf to evaluate the probability density function at given points, and rvs to draw random variate samples, i.e. random points from the distribution.

See examples in Scipy.

to_soerp()[source]

Convert to soerp objects.

TODO: document

to_uncertainties()[source]

Convert to uncertainties objects.

A tuple of numbers with uncertainties (one for each parameter) is returned.

The uncertainties package makes it easy to do error propagation on derived quantities.

See examples in Analyse.