NAME
PDL::Gaussian -- Gaussian distributions.
DESCRIPTION
This package provides a set of standard routines to handle sets gaussian distributions.
A new set of gaussians is initialized by
$a = new PDL::Gaussian(xdims,gdims);
Where xdims is a reference to an array containing the dimensions in the space the gaussian is in and gdimslist is a reference to an array containing the dimensionality of the gaussian space. For example, after
$a = new PDL::Gaussian([2],[3,4]);
$b = new PDL::Gaussian([],[]);
The variable $a contains set of 12 (=3*4) 2-Dimensional gaussians and $b is the simplest form: one 1D gaussian. Currently, xdims may containe either zero or one dimensions due to limitations of PDL::PP.
To set the distribution parameters, you can use the routines
$a->set_covariance($cv); # covariance matrices
$a->set_icovariance($icv); # inverse covariance matrices
$a->set_mu($mu); # centers
The dimensions of $cv and $icv must be (@xdims,@xdims,@gdims) and the dimensions of $mu must be (@xdims,@gdims).
To get a string representation of the gaussians (most useful for debugging) use the routine
$string = $a->asstr();
It is possible to calculate the probability or logarithm of probability of each of the distributions at some points.
$a->calc_value($x,$p);
$a->calc_lnvalue($x,$p);
Here, $x must have dimensions (ndims,...) and $p must have dimensions (gdimslist, ...) where the elipsis represents the same dimensions in both variables. It is usually advisable to work with the logarithms of probabilities to avoid numerical problems.
It is possible to generate the parameters for the gaussians from data. The function
$a->fromweighteddata($data,$wt,$small_covariance);
where data is of dimensions (ndims,npoints) and wt is of dimensions (npoints,gdimslist), analyzes the data statistically and gives a corresponding gaussian distribution. The parameter $small_covariance is the smallest allowed covariance in any direction: if one or more of the eigenvalues of the covariance matrix are smaller than this, they are automatically set to $small_covariance to avoid singularities.
BUGS
DOESN'T REALLY WORK YET
Stupid interface.
Limitation to 0 or 1 x-dimensions is questionable (although it's hard to imagine a case when more is needed).
AUTHOR
Copyright (C) 1996 Tuomas J. Lukka (lukka@fas.harvard.edu)