Christian Soeller >
PDL-2.4.1 >
PDL::Gaussian

PDL::Gaussian -- Gaussian distributions.

$a = new PDL::Gaussian([3],[5]); $a->set_covariance(...)

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

.

Alternatively you can use the routines

$cv = $a->get_covariance(); # cv = reference to covariance matrix ... # Fuzz around with cv $a->upd_covariance(); # update

and similarly for `icovariance`

(inverse covariance). The last sub call is important to update the other parts of the object.

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.

Stupid interface.

Limitation to 1 x-dimensions is questionable (although it's hard to imagine a case when more is needed). Note that this does not mean that you can only have 1-dimensional gaussians. It just means that if you want to have a 6-dimensional gaussian, your xs must be structured like (6) and not (2,3). So clumping the dimensions should make things workable.

Also, it limits you so that even if you have one variable, you need to have the '1' dimensions explicitly everywhere.

Singular distributions are not handled. This should use SVD and be able to handle both infinitely narrow and wide dimensions, preferably so that infinitely narrow dimensions can be queried like `$a-`

relations()> or something like that.

The routines should, if the user requests for it, check all the dimensions of the given arguments for reasonability.

Copyright (C) 1996 Tuomas J. Lukka (lukka@fas.harvard.edu) All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.

syntax highlighting: