distmat

package
v0.0.0-...-dfba71b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package distmat provides probability distributions over matrices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 mat64.Symmetric, nu float64, src *rand.Rand) (*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 mat64.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 *mat64.Cholesky) float64

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

func (*Wishart) MeanSym

func (w *Wishart) MeanSym(x *mat64.SymDense) *mat64.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

func (w *Wishart) ProbSym(x mat64.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

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

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

func (*Wishart) RandSym

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

RandSym generates a random symmetric matrix from the distribution.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL