Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
drwnGaussian Class Reference

Implements a multi-variate gaussian distribution. More...

Inheritance diagram for drwnGaussian:
drwnStdObjIface drwnWriteable drwnCloneable drwnTypeable

Public Member Functions

 drwnGaussian (int n=1)
 construct an n dimensional zero-mean identity-covariance gaussian
 
 drwnGaussian (const VectorXd &mu, double sigma2)
 construct a gaussian with given mean and isotropic covariance
 
 drwnGaussian (const VectorXd &mu, const MatrixXd &sigma2)
 construct a gaussian with given mean and covariance
 
 drwnGaussian (const vector< double > &mu, double sigma2)
 construct a gaussian with given mean and isotropic covariance
 
 drwnGaussian (const drwnSuffStats &stats)
 construct a gaussian from given second-order sufficient statistics
 
 drwnGaussian (const drwnGaussian &model)
 copy constructor
 
void initialize (int n)
 initialize the gaussian to be n dimensional zero-mean and identity-covariance
 
void initialize (const VectorXd &mu, double sigma2)
 initialize the gaussian to have mean mu and isotropic variance sigma2
 
void initialize (const VectorXd &mu, const MatrixXd &sigma2)
 initialize the gaussian to the given mean and covariance
 
drwnGaussianmarginalize (const vector< int > &indx) const
 Generate a gaussian with the variables not in indx marginalized out. The calling function is responsible for deleting the returned object.
 
drwnGaussian reduce (const vector< double > &x, const vector< int > &indx) const
 Returns a gaussian conditioned on x. Repeated calls to reduce on the same set of variables should use the conditionOn function.
 
drwnGaussian reduce (const map< int, double > &x) const
 Returns a gaussian conditioned on x.
 
drwnConditionalGaussian conditionOn (const vector< int > &indx) const
 Returns a temporary objects for conditioning on a set of variables.
 
const char * type () const
 returns object type as a string (e.g., Foo::type() { return "Foo"; })
 
drwnGaussianclone () const
 returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); }
 
bool save (drwnXMLNode &xml) const
 write object to XML node (see also write)
 
bool load (drwnXMLNode &xml)
 read object from XML node (see also read)
 
void evaluate (const MatrixXd &x, VectorXd &p) const
 compute the log-likelihood of each row of X and put the results in p
 
void evaluate (const vector< vector< double > > &x, vector< double > &p) const
 compute the log-likelihood of each vector in x and put the results in p
 
double evaluateSingle (const VectorXd &x) const
 compute the log-likelihood of a given vector
 
double evaluateSingle (const vector< double > &x) const
 compute the log-likelihood of a given vector
 
double evaluateSingle (double x) const
 compute the log-likelihood of a scalar (for one dimensional gaussians only)
 
void sample (VectorXd &x) const
 generate a random sample from the gaussian
 
void sample (vector< double > &x) const
 generate a random sample from the gaussian
 
void train (const MatrixXd &x, double lambda=0.0)
 Estimate the mean and covariance of the gaussian from a matrix of training examples. Data should be arranged row-wise. The parameter lambda can be used to regularize the covariance matrix with an additive isotropic component.
 
void train (const vector< vector< double > > &x, double lambda=0.0)
 See above.
 
void train (const vector< double > &x, double lambda=0.0)
 See above, but for one dimensional gaussians.
 
void train (const drwnSuffStats &stats, double lambda=0.0)
 See above, but using given second-order sufficient statistics.
 
unsigned dimension () const
 returns the dimensionality of the gaussian
 
const VectorXd & mean () const
 returns the mean of the gaussian
 
const MatrixXd & covariance () const
 returns the covariance matrix for the gaussian
 
double logPartitionFunction () const
 computes the log partition function of the gaussian
 
double klDivergence (const drwnGaussian &model) const
 computes the KL divergence between the gaussian and the given model
 
double klDivergence (const drwnSuffStats &stats) const
 computes the KL divergence between the gaussian and distribution induced by the given sufficient statistics
 
drwnGaussianoperator= (const drwnGaussian &model)
 assignment operator
 
- Public Member Functions inherited from drwnWriteable
bool write (const char *filename) const
 write object to file (calls save)
 
bool read (const char *filename)
 read object from file (calls load)
 
void dump () const
 print object's current state to standard output (for debugging)
 

Static Public Attributes

static bool AUTO_RIDGE = false
 

Protected Member Functions

void guaranteeInvSigma () const
 
void freeCachedParameters ()
 
void updateCachedParameters ()
 

Detailed Description

Implements a multi-variate gaussian distribution.

\[ \log p(x; \mu, \Sigma) = -\frac{n}{2} \log(2 \pi) -\frac{1}{2} \log |\Sigma| - \frac{1}{2}\left(x - \mu\right)^T \Sigma^{-1} \left(x - \mu\right) \]

See Also
drwnML Tutorial

The documentation for this class was generated from the following files: