Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 #ifndef PROBLIB_GAUSSIAN_H_
00038 #define PROBLIB_GAUSSIAN_H_
00039 
00040 #include "PDF.h"
00041 
00042 namespace pbl {
00043 
00051 class Gaussian: public PDF {
00052 
00053 public:
00054 
00060         Gaussian(int dim);
00061 
00068         Gaussian(const arma::vec& mean, const arma::mat& cov);
00069 
00073         Gaussian(const Gaussian& orig);
00074 
00078         virtual ~Gaussian();
00079 
00085         Gaussian& operator=(const Gaussian& other);
00086 
00092         Gaussian* clone() const;
00093 
00094         double getLikelihood(const PDF& pdf) const;
00095 
00102         double getDensity(const arma::vec& v, double max_mah_dist = 0) const;
00103 
00104         double getDensity(const Gaussian& npdf, double max_mah_dist = 0) const;
00105 
00111         double getMaxDensity() const;
00112 
00119         bool getExpectedValue(arma::vec& v) const;
00120 
00125         void setMean(const arma::vec& mu);
00126 
00131         void setCovariance(const arma::mat& cov);
00132 
00137         const arma::vec& getMean() const;
00138 
00143         const arma::mat& getCovariance() const;
00144 
00150         std::string toString(const std::string& indent = "") const;
00151 
00152 protected:
00153 
00154         struct GaussianStruct {
00155 
00156                 arma::vec mu_;
00157 
00158                 arma::mat cov_;
00159 
00160                 int n_ptrs_;
00161 
00162                 GaussianStruct(const arma::vec& mu, const arma::mat& cov) : mu_(mu) , cov_(cov), n_ptrs_(1) { }
00163 
00164                 GaussianStruct(const GaussianStruct& orig) : mu_(orig.mu_), cov_(orig.cov_), n_ptrs_(1) { }
00165         };
00166 
00167         GaussianStruct* ptr_;
00168 
00169         void cloneStruct();
00170 
00171         double getDensity(const arma::vec& v1, const arma::vec& v2, const arma::mat& S, double max_mah_dist = 0) const;
00172 
00173 #define CHECK_INITIALIZED assert_msg(ptr_, "Gaussian was not yet initialized.")
00174 
00175 };
00176 
00177 }
00178 
00179 #endif