Bayesian Filtering Library Generated from SVN r
gaussian.h
1// $Id$
2// Copyright (C) 2002 Klaas Gadeyne <first dot last at gmail dot com>
3// Copyright (C) 2008 Tinne De Laet <first dot last at mech dot kuleuven dot be>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation; either version 2.1 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19#ifndef GAUSSIAN_H
20#define GAUSSIAN_H
21
22#include "pdf.h"
23
24namespace BFL
25{
27 class Gaussian: public Pdf<MatrixWrapper::ColumnVector>
28 {
29 private:
30 MatrixWrapper::ColumnVector _Mu;
31 MatrixWrapper::SymmetricMatrix _Sigma;
32
33 // variables to avoid recalculation of inverse
34 mutable bool _Sigma_changed;
35 mutable MatrixWrapper::SymmetricMatrix _Sigma_inverse;
36 mutable double _sqrt_pow;
37 mutable ColumnVector _diff; //needed in probabilityGet
38 mutable ColumnVector _tempColumn; //needed in probabilityGet
39 // variables to avoid allocation on the heap during resampling
40 mutable ColumnVector _samples;
41 mutable ColumnVector _sampleValue;
42 mutable Matrix _Low_triangle;
43
44 public:
46
50 Gaussian (const MatrixWrapper::ColumnVector& Mu, const MatrixWrapper::SymmetricMatrix& Sigma);
51
53 Gaussian (int dimension = 0);
54
56
58 virtual ~Gaussian();
59
61 friend std::ostream& operator<< (std::ostream& os, const Gaussian& g);
62
64 virtual Gaussian* Clone() const;
65
66 // Redefinition of pure virtuals
67 virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector& input) const;
68 bool SampleFrom (vector<Sample<MatrixWrapper::ColumnVector> >& list_samples,
69 const unsigned int num_samples,
70 const SampleMthd method=SampleMthd::DEFAULT,
71 void * args=NULL) const;
72 virtual bool SampleFrom (Sample<MatrixWrapper::ColumnVector>& one_sample, const SampleMthd method=SampleMthd::DEFAULT, void * args=NULL) const;
73
74 virtual MatrixWrapper::ColumnVector ExpectedValueGet() const;
75 virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const;
76 virtual void DimensionSet(unsigned int dim);
77
78 // For a Gaussian this should be possible
80
83 void ExpectedValueSet (const MatrixWrapper::ColumnVector& mu);
84
86
89 void CovarianceSet (const MatrixWrapper::SymmetricMatrix& cov);
90 };
91
92} // end namespace
93#endif
Class representing Gaussian (or normal density)
Definition: gaussian.h:28
virtual ~Gaussian()
Default Copy Constructor will do.
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
virtual MatrixWrapper::ColumnVector ExpectedValueGet() const
Get the expected value E[x] of the pdf.
virtual bool SampleFrom(Sample< MatrixWrapper::ColumnVector > &one_sample, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
Draw 1 sample from the Pdf:
Gaussian(const MatrixWrapper::ColumnVector &Mu, const MatrixWrapper::SymmetricMatrix &Sigma)
Constructor.
virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector &input) const
Get the probability of a certain argument.
virtual Gaussian * Clone() const
Clone function.
void ExpectedValueSet(const MatrixWrapper::ColumnVector &mu)
Set the Expected Value.
bool SampleFrom(vector< Sample< MatrixWrapper::ColumnVector > > &list_samples, const unsigned int num_samples, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
Draw multiple samples from the Pdf (overloaded)
virtual void DimensionSet(unsigned int dim)
Set the dimension of the argument.
Gaussian(int dimension=0)
constructor with only dimensions or nothing
void CovarianceSet(const MatrixWrapper::SymmetricMatrix &cov)
Set the Covariance Matrix.
friend std::ostream & operator<<(std::ostream &os, const Gaussian &g)
output stream for Gaussian
Class PDF: Virtual Base class representing Probability Density Functions.
Definition: pdf.h:51
Class representing a probability (a double between 0 and 1)
Definition: bfl_constants.h:38