RandMultiGauss


Class defining methods for firing multivariate gaussian distributed random values, given a vector of means and a covariance matrix. Definitions are those from 1998 Review of Particle Physics, section 28.3.3.

This utilizes the following other components of CLHEP:

RandGauss from the CLHEP Random package to get individual deviates
HepVector, HepSymMatrix and HepMatrix from the CLHEP Matrix package
HepSymMatrix::similarity(HepMatrix)
diagonalize(HepSymMatrix *s)

The author of this distribution relies on diagonalize() being correct.

Although original distribution classes in the CLHEP Random package return a HepDouble when fire() (or operator()) is done, RandMultiGauss returns a HepVector of values.

Author

Mark Fischler

See also

HepRandomVector

Declaration

#include "CLHEP/RandomObjects/RandMultiGauss.h"

class RandMultiGauss : public HepRandomVector

Public Member Functions

Constructors
RandMultiGauss(HepRandomEngine& anEngine, const HepVector& mu, const HepSymMatrix& S)
The symmetric matrix S must be positive definite and must match the size of mu.

RandMultiGauss(HepRandomEngine* anEngine, const HepVector& mu, const HepSymMatrix& S)
The symmetric matrix S must be positive definite and must match the size of mu.

These constructors should be used to instantiate a RandMultiGauss distribution object defining a local engine for it.
The static generator will be skipped using the non-static methods defined below.
If the engine is passed by pointer the corresponding engine object will be deleted by the RandMultiGauss destructor.
If the engine is passed by reference the corresponding engine object will not be deleted by the RandGauss destructor.

RandMultiGauss(HepRandomEngine& anEngine)
RandMultiGauss(HepRandomEngine* anEngine)
These constructors are provided for convenience in the case where each random fired will have a different mu and S.
They set the default mu to the zero 2-vector, and the default S to the Unit 2x2 matrix.
Destructor
virtual ~RandMultiGauss()
()
HepVector operator()()
HepVector operator()(const HepVector& mu, const HepSymMatrix& S )
The symmetric matrix S must be positive definite and must match the size of mu.
fire
HepVector fire()
HepVector fire(const HepVector& mu, const HepSymMatrix& S)
The symmetric matrix S must be positive definite and must match the size of mu.

A note on efficient usage when firing many vectors of Multivariate Gaussians:
For n > 2 the work needed to diagonalize S is significant.
So if you only want a collection of uncorrelated Gaussians, it will be quicker to generate them one at a time.

The class saves the diagonalizing matrix for the default S.
Thus generating vectors with that same S can be quite efficient.
If you require a small number of different S's, known in advance, consider instantiating RandMulitGauss for each different S, sharing the same engine.

If you require a random using the default S for a distribution but a different mu, it is most efficient to imply use the default fire() and add the difference of the mu's to the returned HepVector.
fireArray
void fireArray(const HepInt size, HepVector* array)
void fireArray(const HepInt size, HepVector* array, const HepVector& mu, const HepSymMatrix& S)
The symmetric matrix S must be positive definite and must match the size of mu.

Example

CLHEP/test/testVectorDists.cc


19 June 2001
EVC