/** 
* @file PDFGaussian.h
* @brief Normal Distribution / Gaussian PDF
* @author Erik Rodner
* @date 01/29/2008

*/
#ifndef PDFGAUSSIANINCLUDE
#define PDFGAUSSIANINCLUDE

#include "core/vector/VectorT.h"
#include "core/vector/MatrixT.h"

#include <map>
#include "PDF.h"


namespace OBJREC {

/** Normal Distribution / Gaussian PDF */
class PDFGaussian : public PDF
{

    protected:
	double constant;
	double ldet;
	NICE::Matrix covariance;
	NICE::Matrix covCholesky;
	NICE::Vector mean;

	/** empty constructor */
	PDFGaussian ( int dimension );

#if __cplusplus >= 201103L
	static constexpr double logdetEPS = 0.0;
	static constexpr double regEPS = 1e-7;
#else
	static const double logdetEPS = 0.0;
	static const double regEPS = 1e-7;
#endif
	static NICE::Matrix RobustInverse ( const NICE::Matrix & M, double & logdet );

    public:
  
	/** simple constructor */
	PDFGaussian ( const NICE::Matrix & covariance, const NICE::Vector & mean );

	/** simple destructor */
	virtual ~PDFGaussian();
 
	double getNLogDensity ( const NICE::Vector & x ) const;
	int getDimension () const;

	/**
	 * get Mean of PDF
	 * @return mean vector
	 */
	NICE::Vector getMean();
        
	/**
	 * get Covariance of PDF
	 * @return covariance matrix
	 */
	NICE::Matrix getCovariance();
	
	/**
	 *  get multivariate samples
	 * @param samples vector of NICE::Vector
	 * @param count number of samples
	 */
	void sample ( NICE::VVector & samples, int count ) const;
};


} // namespace

#endif
