{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _multivariate / matrix_normal_gen

class

scipy.stats._multivariate:matrix_normal_gen

source: /scipy/stats/_multivariate.py :1113

Signature

class   matrix_normal_gen ( seed = None )

Members

Summary

A matrix normal random variable.

Extended Summary

The mean keyword specifies the mean. The rowcov keyword specifies the among-row covariance matrix. The 'colcov' keyword specifies the among-column covariance matrix.

Parameters

%(_matnorm_doc_default_callparams)s
%(_doc_random_state)s

Methods

pdf(X, mean=None, rowcov=1, colcov=1)

Probability density function.

logpdf(X, mean=None, rowcov=1, colcov=1)

Log of the probability density function.

rvs(mean=None, rowcov=1, colcov=1, size=1, random_state=None)

Draw random samples.

entropy(rowcol=1, colcov=1)

Differential entropy.

Notes

%(_matnorm_doc_callparams_note)s

The covariance matrices specified by rowcov and colcov must be (symmetric) positive definite. If the samples in X are , then rowcov must be and colcov must be . mean must be the same shape as X.

The probability density function for matrix_normal is

where is the mean, the among-row covariance matrix, the among-column covariance matrix.

The allow_singular behaviour of the multivariate_normal distribution is not currently supported. Covariance matrices must be full rank.

The matrix_normal distribution is closely related to the multivariate_normal distribution. Specifically, (the vector formed by concatenating the columns of ) has a multivariate normal distribution with mean and covariance (where is the Kronecker product). Sampling and pdf evaluation are for the matrix normal, but for the equivalent multivariate normal, making this equivalent form algorithmically inefficient.

Examples

import numpy as np
from scipy.stats import matrix_normal
M = np.arange(6).reshape(3,2); M
U = np.diag([1,2,3]); U
V = 0.3*np.identity(2); V
X = M + 0.1; X
matrix_normal.pdf(X, mean=M, rowcov=U, colcov=V)
from scipy.stats import multivariate_normal
vectorised_X = X.T.flatten()
equiv_mean = M.T.flatten()
equiv_cov = np.kron(V,U)
multivariate_normal.pdf(vectorised_X, mean=equiv_mean, cov=equiv_cov)
Alternatively, the object may be called (as a function) to fix the mean and covariance parameters, returning a "frozen" matrix normal random variable:
rv = matrix_normal(mean=None, rowcov=1, colcov=1)

Aliases

  • scipy.stats._multivariate.matrix_normal_gen