Template Class CProbabilityDensityFunction

Class Documentation

template<class TDATA, size_t STATE_LEN>
class CProbabilityDensityFunction

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

Public Types

using type_value = TDATA

The type of the state the PDF represents

using self_t = CProbabilityDensityFunction<TDATA, STATE_LEN>
using cov_mat_t = mrpt::math::CMatrixFixed<double, STATE_LEN, STATE_LEN>

Covariance matrix type

using inf_mat_t = cov_mat_t

Information matrix type

Public Functions

virtual ~CProbabilityDensityFunction() = default
CProbabilityDensityFunction() = default
CProbabilityDensityFunction(const CProbabilityDensityFunction&) = default
CProbabilityDensityFunction(CProbabilityDensityFunction&&) = default
CProbabilityDensityFunction &operator=(const CProbabilityDensityFunction&) = default
CProbabilityDensityFunction &operator=(CProbabilityDensityFunction&&) = default
virtual void getMean(type_value &mean_point) const = 0

Returns the mean, or mathematical expectation of the probability density distribution (PDF).

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.

inline virtual void getCovarianceAndMean(cov_mat_t &c, TDATA &mean) const final

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

inline 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.

inline type_value getMeanVal() const

Returns the mean, or mathematical expectation of the probability density distribution (PDF).

inline void getCovariance(mrpt::math::CMatrixDouble &cov) const

Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)

inline void getCovariance(cov_mat_t &cov) const

Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)

inline cov_mat_t getCovariance() const

Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)

inline virtual bool isInfType() const

Returns whether the class instance holds the uncertainty in covariance or information form.

See also

mrpt::traits::is_inf_type

Note

By default this is going to be covariance form. *Inf classes (e.g. CPosePDFGaussianInf) store it in information form.

inline 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.

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

inline 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.

inline double getCovarianceEntropy() const

Compute the entropy of the estimated covariance matrix.

Public Static Attributes

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).