{ } Raw JSON

bundles / scipy latest / scipy / stats / _multivariate / wishart_gen

class

scipy.stats._multivariate:wishart_gen

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

Signature

class   wishart_gen ( seed = None )

Members

Summary

A Wishart random variable.

Extended Summary

The df keyword specifies the degrees of freedom. The scale keyword specifies the scale matrix, which must be symmetric and positive definite. In this context, the scale matrix is often interpreted in terms of a multivariate normal precision matrix (the inverse of the covariance matrix). These arguments must satisfy the relationship df > scale.ndim - 1, but see notes on using the rvs method with df < scale.ndim.

Parameters

%(_doc_default_callparams)s
%(_doc_random_state)s

Methods

pdf(x, df, scale)

Probability density function.

logpdf(x, df, scale)

Log of the probability density function.

rvs(df, scale, size=1, random_state=None)

Draw random samples from a Wishart distribution.

entropy()

Compute the differential entropy of the Wishart distribution.

Raises

: scipy.linalg.LinAlgError

If the scale matrix scale is not positive definite.

Notes

%(_doc_callparams_note)s

The scale matrix scale must be a symmetric positive definite matrix. Singular matrices, including the symmetric positive semi-definite case, are not supported. Symmetry is not checked; only the lower triangular portion is used.

The Wishart distribution is often denoted

where is the degrees of freedom and is the scale matrix.

The probability density function for wishart has support over positive definite matrices ; if , then its PDF is given by:

If (Wishart) then (inverse Wishart).

If the scale matrix is 1-dimensional and equal to one, then the Wishart distribution collapses to the distribution.

The algorithm [2] implemented by the rvs method may produce numerically singular matrices with ; the user may wish to check for this condition and generate replacement samples as necessary.

Examples

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import wishart, chi2
x = np.linspace(1e-5, 8, 100)
w = wishart.pdf(x, df=3, scale=1); w[:5]
c = chi2.pdf(x, 3); c[:5]
plt.plot(x, w)
plt.show()
fig-7ffe10647d125a35.png
The input quantiles can be any shape of array, as long as the last axis labels the components. Alternatively, the object may be called (as a function) to fix the degrees of freedom and scale parameters, returning a "frozen" Wishart random variable:
rv = wishart(df=1, scale=1)

See also

chi2
invwishart

Aliases

  • scipy.stats._multivariate.wishart_gen