gonum: gonum.org/v1/gonum/stat/distmat Index | Files

package distmat

import "gonum.org/v1/gonum/stat/distmat"

Package distmat provides probability distributions over matrices.


Package Files

doc.go general.go wishart.go

type Wishart Uses

type Wishart struct {
    // contains filtered or unexported fields

Wishart is a distribution over d×d positive symmetric definite matrices. It is parametrized by a scalar degrees of freedom parameter ν and a d×d positive definite matrix V.

The Wishart PDF is given by

p(X) = [|X|^((ν-d-1)/2) * exp(-tr(V^-1 * X)/2)] / [2^(ν*d/2) * |V|^(ν/2) * Γ_d(ν/2)]

where X is a d×d PSD matrix, ν > d-1, |·| denotes the determinant, tr is the trace and Γ_d is the multivariate gamma function.

See https://en.wikipedia.org/wiki/Wishart_distribution for more information.

func NewWishart Uses

func NewWishart(v mat.Symmetric, nu float64, src rand.Source) (*Wishart, bool)

NewWishart returns a new Wishart distribution with the given shape matrix and degrees of freedom parameter. NewWishart returns whether the creation was successful.

NewWishart panics if nu <= d - 1 where d is the order of v.

func (*Wishart) LogProbSym Uses

func (w *Wishart) LogProbSym(x mat.Symmetric) float64

LogProbSym returns the log of the probability of the input symmetric matrix.

LogProbSym returns -∞ if the input matrix is not positive definite (the Cholesky decomposition fails).

func (*Wishart) LogProbSymChol Uses

func (w *Wishart) LogProbSymChol(cholX *mat.Cholesky) float64

LogProbSymChol returns the log of the probability of the input symmetric matrix given its Cholesky decomposition.

func (*Wishart) MeanSym Uses

func (w *Wishart) MeanSym(x *mat.SymDense) *mat.SymDense

MeanSym returns the mean matrix of the distribution as a symmetric matrix. If x is nil, a new matrix is allocated and returned. If x is not nil, the result is stored in-place into x and MeanSym will panic if the order of x is not equal to the order of the receiver.

func (*Wishart) ProbSym Uses

func (w *Wishart) ProbSym(x mat.Symmetric) float64

ProbSym returns the probability of the symmetric matrix x. If x is not positive definite (the Cholesky decomposition fails), it has 0 probability.

func (*Wishart) RandChol Uses

func (w *Wishart) RandChol(c *mat.Cholesky) *mat.Cholesky

RandChol generates the Cholesky decomposition of a random matrix from the distribution.

func (*Wishart) RandSym Uses

func (w *Wishart) RandSym(x *mat.SymDense) *mat.SymDense

RandSym generates a random symmetric matrix from the distribution.

Package distmat imports 6 packages (graph). Updated 2019-03-31. Refresh now. Tools for package owners.