Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

RazorBack::Mvn_ Class Reference

Mvn_: a class representing multivariate Normal distributions. More...

#include <Mvn.hh>

List of all members.

Public Methods

 Mvn_ (size_t D=2)
 Inits to store a D-dimensional MVN centered on the origin, unit covariance matrix (standard MVN).

 Mvn_ (const Vecdbl_ &Avg, const Smatdbl_ &Cov)
 Inits to store a MVN distribution with average A and covariance matrix C. More...

size_t dim () const
 dim(): returns the actual dimension.

size_t dim (size_t D)
 dim(D): adjusts the calling object to represent a D-dimensional MVN distribution. More...

size_t covrank () const
 covrank(): returns the rank of the covariance matrix. More...

const Vecdbl_& avg () const
 avg(): returns a const ref. to the average of the distribution.

void avg (const Vecdbl_ &Newavg)
 avg(Newavg): sets the average of the distribution to Newavg.

const Smatdbl_& covar () const
 covar(): returns a const ref. to the covariance of the distribution.

int covar (const Smatdbl_ &Newcov)
 covar(Newcov): sets the covariance of the distribution to Newcov if Newcov has the same dimension as the calling object and if it has at least rank 2. More...

double pdf (const Vecdbl_ &X) const
 pdf(X): calculates the probability density function of the calling object at point X.

void random (Vecdbl_ &X) const
 random(X): generates a dim()-dimensional random vector from the MVN distribution stored in the calling object. More...

double maha_dist (const Vecdbl_ &X) const
 maha_dist(X): calculates and returns the Mahalanobis distance between X and the average vector in the calling object.

size_t marginal (const Bits_ &Bitmask, Mvn_ &Marginal) const
 marginal(Bitmask, Marginal): changes Marginal so that it contains a marginal distribution of the calling object. More...


Private Attributes

size_t Dim
size_t Covrank
 dimension of random vector, covar mtx rank.

Vecdbl_ Avgvec
 average.

Smatdbl_ Covarmat
 covariance matrix.

Vecdbl_ Eval
 eigenvalues of Covarmat.

Rmatdbl_ Evec
 eigenvectors of Covarmat.

Rmatdbl_ Stdnmap
 lin. comb. coeffs that map N(0,1)-s onto MVN.

double Normfactor
 the density normalisation factor.


Static Private Attributes

const double TWO_PI

Friends

istream& operator>> (istream &In, Mvn_ &Mvn)
 Input from stream In. More...

ostream& operator<< (ostream &Out, const Mvn_ &Mvn)
 Output to stream Out.


Detailed Description

Mvn_: a class representing multivariate Normal distributions.

Can be asked to calculate the MVN density and to generate MVN-distributed random vectors. I/O is provided.

Definition at line 44 of file Mvn.hh.


Constructor & Destructor Documentation

RazorBack::Mvn_::Mvn_ ( size_t D = 2 ) [explicit]
 

Inits to store a D-dimensional MVN centered on the origin, unit covariance matrix (standard MVN).

RazorBack::Mvn_::Mvn_ ( const Vecdbl_ & Avg,
const Smatdbl_ & Cov )
 

Inits to store a MVN distribution with average A and covariance matrix C.

These should have the same dimension of course.


Member Function Documentation

size_t RazorBack::Mvn_::dim ( ) const [inline]
 

dim(): returns the actual dimension.

Definition at line 78 of file Mvn.hh.

Referenced by avg().

size_t RazorBack::Mvn_::dim ( size_t D )
 

dim(D): adjusts the calling object to represent a D-dimensional MVN distribution.

If D<2 then it will be set to 2 silently. Does nothing if D is the same as the previous dimension. Do not forget to call avg(Newavg) and covar(Newcov) afterwards! Return value: the old dimension.

size_t RazorBack::Mvn_::covrank ( ) const [inline]
 

covrank(): returns the rank of the covariance matrix.

It is always true that covrank()<=dim().

Definition at line 93 of file Mvn.hh.

const Vecdbl_ & RazorBack::Mvn_::avg ( ) const [inline]
 

avg(): returns a const ref. to the average of the distribution.

Definition at line 96 of file Mvn.hh.

void RazorBack::Mvn_::avg ( const Vecdbl_ & Newavg ) [inline]
 

avg(Newavg): sets the average of the distribution to Newavg.

Definition at line 99 of file Mvn.hh.

const Smatdbl_ & RazorBack::Mvn_::covar ( ) const [inline]
 

covar(): returns a const ref. to the covariance of the distribution.

Definition at line 107 of file Mvn.hh.

int RazorBack::Mvn_::covar ( const Smatdbl_ & Newcov )
 

covar(Newcov): sets the covariance of the distribution to Newcov if Newcov has the same dimension as the calling object and if it has at least rank 2.

Otherwise nothing is changed. Return value: the rank if OK or 0 on error.

double RazorBack::Mvn_::pdf ( const Vecdbl_ & X ) const [inline]
 

pdf(X): calculates the probability density function of the calling object at point X.

Definition at line 121 of file Mvn.hh.

void RazorBack::Mvn_::random ( Vecdbl_ & X ) const
 

random(X): generates a dim()-dimensional random vector from the MVN distribution stored in the calling object.

The dimension of X is adjusted silently, previous contents are overwritten.

double RazorBack::Mvn_::maha_dist ( const Vecdbl_ & X ) const
 

maha_dist(X): calculates and returns the Mahalanobis distance between X and the average vector in the calling object.

Referenced by pdf().

size_t RazorBack::Mvn_::marginal ( const Bits_ & Bitmask,
Mvn_ & Marginal ) const
 

marginal(Bitmask, Marginal): changes Marginal so that it contains a marginal distribution of the calling object.

The variables corresponding to the bits set in Bitmask will be kept, the others will be "integrated out". E.g. if the calling object is a 4-dim MVN with PDF(x1,x2,x3,x4), and the bitmask is "1010", then Marginal will be a 2-dim MVN with PDF(x2,x4). The bitmask should contain exactly as many bits as dim(), otherwise a Dimexc_ exception will be thrown. At least two bits must be set to ON so that Marginal remains a valid Mvn_ object; otherwise a warning is printed and no action will be taken. To get a 1-D marginal distribution, simply obtain the corresponding average coordinate and variance and use a Gaussian_ object. Return value: the dimension of Marginal.


Friends And Related Function Documentation

istream & operator>> ( istream & In,
Mvn_ & Mvn ) [friend]
 

Input from stream In.

The ASCII format of an Mvn_ object is:-

      MVN
      AVERAGE
      <dbl vector>     (center of distribution)
      COVARIANCE
      <dbl lower triangular matrix>    (covariance matrix)
      ENDMVN
      
For the formats of the vectors and matrices, see the corresponding linalg header files. Empty lines are allowed, lines starting with '#' are comments.

ostream & operator<< ( ostream & Out,
const Mvn_ & Mvn ) [friend]
 

Output to stream Out.


Member Data Documentation

const double RazorBack::Mvn_::TWO_PI [static, private]
 

Definition at line 49 of file Mvn.hh.

size_t RazorBack::Mvn_::Dim [private]
 

Definition at line 54 of file Mvn.hh.

size_t RazorBack::Mvn_::Covrank [private]
 

dimension of random vector, covar mtx rank.

Definition at line 54 of file Mvn.hh.

Vecdbl_ RazorBack::Mvn_::Avgvec [private]
 

average.

Definition at line 55 of file Mvn.hh.

Smatdbl_ RazorBack::Mvn_::Covarmat [private]
 

covariance matrix.

Definition at line 56 of file Mvn.hh.

Vecdbl_ RazorBack::Mvn_::Eval [private]
 

eigenvalues of Covarmat.

Definition at line 57 of file Mvn.hh.

Rmatdbl_ RazorBack::Mvn_::Evec [private]
 

eigenvectors of Covarmat.

Definition at line 58 of file Mvn.hh.

Rmatdbl_ RazorBack::Mvn_::Stdnmap [private]
 

lin. comb. coeffs that map N(0,1)-s onto MVN.

Definition at line 59 of file Mvn.hh.

double RazorBack::Mvn_::Normfactor [private]
 

the density normalisation factor.

Definition at line 60 of file Mvn.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:17 2002 for The Razorback C++ Library: Statistics by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001