102 assert_msg(
false,
"Gaussian: Likelihood can only be calculated with another Gaussian or Uniform pdf.");
130 assert(v1.n_elem == v2.n_elem && v1.n_elem == S.n_rows);
144 assert(mahalanobis_dist_sq >= 0);
147 if (max_mah_dist > 0 && mahalanobis_dist_sq > (max_mah_dist * max_mah_dist)) {
152 for(
unsigned int d = 0;
d < S.n_rows; ++
d) {
157 double pos_sqrt_pow = 1 /
sqrt(pi2_pow * det);
158 return exp(-0.5 * mahalanobis_dist_sq) * pos_sqrt_pow;
bool getExpectedValue(arma::vec &v) const
Returns the expected value E[x] of the Gaussian, which corresponds to its mean.
arma_inline arma_warn_unused T1::elem_type dot(const Base< typename T1::elem_type, T1 > &A, const Base< typename T1::elem_type, T2 > &B)
arma_inline const eOp< T1, eop_exp > exp(const Base< typename T1::elem_type, T1 > &A)
arma_hot const Col< eT > & zeros()
arma_inline const eOp< T1, eop_sqrt > sqrt(const Base< typename T1::elem_type, T1 > &A)
virtual ~Gaussian()
Destructor.
#define assert_msg(_Expression, _Msg)
This class represents a multi-variate Gaussian (Normal) distribution.
Gaussian & operator=(const Gaussian &other)
Assignment operator. The operation is cheap since it only copies a pointer. A deep clone will only be...
double getMaxDensity() const
Calculates the maximum density of the Gaussian, i.e., the density at the mean.
const arma::mat & getCovariance() const
Returns the covariance matrix of the Gaussian.
void setMean(const arma::vec &mu)
Sets the mean of the Gaussian.
const arma::vec & getMean() const
Returns the mean of the Gaussian.
static bool inv(Mat< eT > &out, const Base< eT, T1 > &X, const bool slow=false)
#define CHECK_INITIALIZED
double getLikelihood(const PDF &pdf) const
Gaussian(int dim)
Constructs a (multi-variate) Gaussian with specific dimensionality but leaves mean and covariance uns...
const Op< T1, op_cov > cov(const Base< typename T1::elem_type, T1 > &X, const uword norm_type=0)
double getDensity(const arma::vec &v, double max_mah_dist=0) const
Calculates the density of the Gaussian at point v.
static eT det(const Base< eT, T1 > &X, const bool slow=false)
Gaussian * clone() const
Creates a clone of the object. The clone method is cheap since it only copies a pointer. A deep clone will only be created if the original object is modified.
void setCovariance(const arma::mat &cov)
Sets the covariance of the Gaussian.
std::string toString(const std::string &indent="") const
Represents the Gaussian as a string for easier console output.