template class mrpt::math::CProbabilityDensityFunction
Overview
A generic template for probability density distributions (PDFs).
This template is used as base for many classes in mrpt::poses Any derived class must implement getMean() and a getCovarianceAndMean(). Other methods such as getMean() or getCovariance() are implemented here for convenience.
See also:
mprt::poses::CPosePDF, mprt::poses::CPose3DPDF, mprt::poses::CPointPDF
#include <mrpt/math/CProbabilityDensityFunction.h> template <class TDATA, size_t STATE_LEN> class CProbabilityDensityFunction { public: // typedefs typedef TDATA type_value; typedef CProbabilityDensityFunction<TDATA, STATE_LEN> self_t; typedef mrpt::math::CMatrixFixed<double, STATE_LEN, STATE_LEN> cov_mat_t; typedef cov_mat_t inf_mat_t; // fields static constexpr size_t state_length = STATE_LEN; // construction CProbabilityDensityFunction(); CProbabilityDensityFunction(const CProbabilityDensityFunction&); CProbabilityDensityFunction(CProbabilityDensityFunction&&); // methods CProbabilityDensityFunction& operator = (const CProbabilityDensityFunction&); CProbabilityDensityFunction& operator = (CProbabilityDensityFunction&&); virtual void getMean(type_value& mean_point) const = 0; virtual std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const = 0; virtual void getCovarianceAndMean(cov_mat_t& c, TDATA& mean) const; void getCovarianceDynAndMean(mrpt::math::CMatrixDouble& cov, type_value& mean_point) const; type_value getMeanVal() const; void getCovariance(mrpt::math::CMatrixDouble& cov) const; void getCovariance(cov_mat_t& cov) const; cov_mat_t getCovariance() const; virtual bool isInfType() const; virtual void getInformationMatrix(inf_mat_t& inf) const; virtual bool saveToTextFile(const std::string& file) const = 0; virtual void drawSingleSample(TDATA& outPart) const = 0; virtual void drawManySamples(size_t N, std::vector<mrpt::math::CVectorDouble>& outSamples) const; double getCovarianceEntropy() const; }; // direct descendants class CPoint2DPDF; class CPointPDF; class CPose3DPDF; class CPose3DQuatPDF; class CPosePDF;
Typedefs
typedef TDATA type_value
The type of the state the PDF represents.
typedef mrpt::math::CMatrixFixed<double, STATE_LEN, STATE_LEN> cov_mat_t
Covariance matrix type.
typedef cov_mat_t inf_mat_t
Information matrix type.
Fields
static constexpr size_t state_length = STATE_LEN
The length of the variable, for example, 3 for a 3D point, 6 for a 3D pose (x y z yaw pitch roll).
Methods
virtual void getMean(type_value& mean_point) const = 0
Returns the mean, or mathematical expectation of the probability density distribution (PDF).
See also:
getCovarianceAndMean, getInformationMatrix
virtual std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const = 0
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean, both at once.
See also:
virtual void getCovarianceAndMean(cov_mat_t& c, TDATA& mean) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void getCovarianceDynAndMean(mrpt::math::CMatrixDouble& cov, type_value& mean_point) const
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean, both at once.
See also:
type_value getMeanVal() const
Returns the mean, or mathematical expectation of the probability density distribution (PDF).
See also:
getCovariance, getInformationMatrix
void getCovariance(mrpt::math::CMatrixDouble& cov) const
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)
See also:
getMean, getCovarianceAndMean, getInformationMatrix
void getCovariance(cov_mat_t& cov) const
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)
See also:
getMean, getCovarianceAndMean, getInformationMatrix
cov_mat_t getCovariance() const
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)
See also:
virtual bool isInfType() const
Returns whether the class instance holds the uncertainty in covariance or information form.
By default this is going to be covariance form. *Inf classes (e.g. CPosePDFGaussianInf) store it in information form.
See also:
mrpt::traits::is_inf_type
virtual void getInformationMatrix(inf_mat_t& inf) const
Returns the information (inverse covariance) matrix (a STATE_LEN x STATE_LEN matrix) Unless reimplemented in derived classes, this method first reads the covariance, then invert it.
See also:
virtual bool saveToTextFile(const std::string& file) const = 0
Save PDF’s particles to a text file.
See derived classes for more information about the format of generated files.
Returns:
false on error
virtual void drawSingleSample(TDATA& outPart) const = 0
Draws a single sample from the distribution.
virtual void drawManySamples(size_t N, std::vector<mrpt::math::CVectorDouble>& outSamples) const
Draws a number of samples from the distribution, and saves as a list of 1xSTATE_LEN vectors, where each row contains a (x,y,z,yaw,pitch,roll) datum.
This base method just call N times to drawSingleSample, but derived classes should implemented optimized method for each particular PDF.
double getCovarianceEntropy() const
Compute the entropy of the estimated covariance matrix.
See also:
http://en.wikipedia.org/wiki/Multivariate_normal_distribution#Entropy