gaussian.h
Go to the documentation of this file.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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:
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 int num_samples,
70  int method=DEFAULT,
71  void * args=NULL) const;
72  virtual bool SampleFrom (Sample<MatrixWrapper::ColumnVector>& one_sample, int method=DEFAULT, void * args=NULL) const;
73 
74  virtual MatrixWrapper::ColumnVector ExpectedValueGet() const;
75  virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const;
76 
77  // For a Gaussian this should be possible
79 
82  void ExpectedValueSet (const MatrixWrapper::ColumnVector& mu);
83 
85 
88  void CovarianceSet (const MatrixWrapper::SymmetricMatrix& cov);
89  };
90 
91 } // end namespace
92 #endif
void ExpectedValueSet(const MatrixWrapper::ColumnVector &mu)
Set the Expected Value.
Definition: gaussian.cpp:193
Class PDF: Virtual Base class representing Probability Density Functions.
Definition: pdf.h:53
virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector &input) const
Get the probability of a certain argument.
Definition: gaussian.cpp:75
ColumnVector _samples
Definition: gaussian.h:40
#define DEFAULT
friend std::ostream & operator<<(std::ostream &os, const Gaussian &g)
output stream for Gaussian
Definition: gaussian.cpp:62
MatrixWrapper::ColumnVector _Mu
Definition: gaussian.h:30
Class representing Gaussian (or normal density)
Definition: gaussian.h:27
bool _Sigma_changed
Definition: gaussian.h:34
MatrixWrapper::SymmetricMatrix _Sigma
Definition: gaussian.h:31
MatrixWrapper::SymmetricMatrix _Sigma_inverse
Definition: gaussian.h:35
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
Definition: gaussian.cpp:187
bool SampleFrom(vector< Sample< MatrixWrapper::ColumnVector > > &list_samples, const int num_samples, int method=DEFAULT, void *args=NULL) const
virtual ~Gaussian()
Default Copy Constructor will do.
Definition: gaussian.cpp:60
Gaussian(const MatrixWrapper::ColumnVector &Mu, const MatrixWrapper::SymmetricMatrix &Sigma)
Constructor.
Matrix _Low_triangle
Definition: gaussian.h:42
virtual Gaussian * Clone() const
Clone function.
Definition: gaussian.cpp:70
ColumnVector _diff
Definition: gaussian.h:37
ColumnVector _tempColumn
Definition: gaussian.h:38
void CovarianceSet(const MatrixWrapper::SymmetricMatrix &cov)
Set the Covariance Matrix.
Definition: gaussian.cpp:204
ColumnVector _sampleValue
Definition: gaussian.h:41
double _sqrt_pow
Definition: gaussian.h:36
Class representing a probability (a double between 0 and 1)
Definition: bfl_constants.h:39
virtual MatrixWrapper::ColumnVector ExpectedValueGet() const
Get the expected value E[x] of the pdf.
Definition: gaussian.cpp:181


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Feb 28 2022 21:56:33