Back to godoc.org
gonum.org/v1/gonum / stat / distmat

Package distmat

v0.7.0
Latest Go to latest
Published: Feb 26, 2020 | License: BSD-3-Clause | Module: gonum.org/v1/gonum

Overview

Package distmat provides probability distributions over matrices.

Index

Package Files

type Wishart

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

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

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

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) MeanSymTo

func (w *Wishart) MeanSymTo(dst *mat.SymDense)

MeanSymTo calculates the mean matrix of the distribution in and stores it in dst. If dst is empty, it is resized to be an d×d symmetric matrix where d is the order of the receiver. When dst is non-empty, MeanSymTo panics if dst is not d×d.

func (*Wishart) ProbSym

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) RandCholTo

func (w *Wishart) RandCholTo(dst *mat.Cholesky)

RandCholTo generates the Cholesky decomposition of a random matrix from the distribution. If dst is empty, it is resized to be an d×d symmetric matrix where d is the order of the receiver. When dst is non-empty, RandCholTo panics if dst is not d×d.

func (*Wishart) RandSymTo

func (w *Wishart) RandSymTo(dst *mat.SymDense)

RandSymTo generates a random symmetric matrix from the distribution. If dst is empty, it is resized to be an d×d symmetric matrix where d is the order of the receiver. When dst is non-empty, RandSymTo panics if dst is not d×d.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier