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 
24 namespace BFL
25 {
27  class Gaussian: public Pdf<MatrixWrapper::ColumnVector>
28  {
29  private:
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 
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 
84 
86 
90  };
91 
92 } // end namespace
93 #endif
MatrixWrapper::SymmetricMatrix
Definition: matrix_BOOST.h:109
BFL::Gaussian::CovarianceSet
void CovarianceSet(const MatrixWrapper::SymmetricMatrix &cov)
Set the Covariance Matrix.
BFL::Gaussian
Class representing Gaussian (or normal density)
Definition: gaussian.h:27
BFL::Gaussian::operator<<
friend std::ostream & operator<<(std::ostream &os, const Gaussian &g)
output stream for Gaussian
BFL::Gaussian::DimensionSet
virtual void DimensionSet(unsigned int dim)
Set the dimension of the argument.
BFL::Gaussian::Gaussian
Gaussian(const MatrixWrapper::ColumnVector &Mu, const MatrixWrapper::SymmetricMatrix &Sigma)
Constructor.
BFL::Sample
Definition: sample.h:73
MatrixWrapper::ColumnVector
Wrapper class for ColumnVectors (Boost implementation)
Definition: vector_BOOST.h:41
BFL::Gaussian::SampleFrom
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)
BFL::Gaussian::~Gaussian
virtual ~Gaussian()
Default Copy Constructor will do.
BFL::Gaussian::ExpectedValueSet
void ExpectedValueSet(const MatrixWrapper::ColumnVector &mu)
Set the Expected Value.
BFL::Gaussian::Clone
virtual Gaussian * Clone() const
Clone function.
BFL::Probability
Class representing a probability (a double between 0 and 1)
Definition: bfl_constants.h:37
BFL::Gaussian::ProbabilityGet
virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector &input) const
Get the probability of a certain argument.
BFL::Pdf
Class PDF: Virtual Base class representing Probability Density Functions.
Definition: pdf.h:76