class mrpt::poses::CPoint2DPDFGaussian

Overview

A gaussian distribution for 2D points.

Also a method for bayesian fusion is provided.

See also:

CPoint2DPDF

#include <mrpt/poses/CPoint2DPDFGaussian.h>

class CPoint2DPDFGaussian: public mrpt::poses::CPoint2DPDF
{
public:
    // enums

    enum
    {
        is_3D_val = 0,
    };

    enum
    {
        is_PDF_val = 1,
    };

    // fields

    CPoint2D mean;
    mrpt::math::CMatrixDouble22 cov;

    // construction

    CPoint2DPDFGaussian();
    CPoint2DPDFGaussian(const CPoint2D& init_Mean);
    CPoint2DPDFGaussian(const CPoint2D& init_Mean, const mrpt::math::CMatrixDouble22& init_Cov);

    // methods

    void getMean(CPoint2D& p) const;
    virtual std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const;
    virtual void copyFrom(const CPoint2DPDF& o);
    virtual bool saveToTextFile(const std::string& file) const;
    virtual void changeCoordinatesReference(const CPose3D& newReferenceBase);
    void bayesianFusion(const CPoint2DPDFGaussian& p1, const CPoint2DPDFGaussian& p2);
    double productIntegralWith(const CPoint2DPDFGaussian& p) const;
    double productIntegralNormalizedWith(const CPoint2DPDFGaussian& p) const;
    void drawSingleSample(CPoint2D& outSample) const;
    virtual void bayesianFusion(const CPoint2DPDF& p1, const CPoint2DPDF& p2, const double minMahalanobisDistToDrop = 0);
    double mahalanobisDistanceTo(const CPoint2DPDFGaussian& other) const;
    double mahalanobisDistanceToPoint(const double x, const double y) const;
    static constexpr bool is_3D();
    static constexpr bool is_PDF();
};

Inherited Members

public:
    // typedefs

    typedef CProbabilityDensityFunction<TDATA, STATE_LEN> self_t;

    // methods

    virtual void copyFrom(const CPoint2DPDF& o) = 0;
    virtual void changeCoordinatesReference(const CPose3D& newReferenceBase) = 0;
    virtual void bayesianFusion(const CPoint2DPDF& p1, const CPoint2DPDF& p2, const double minMahalanobisDistToDrop = 0) = 0;
    virtual std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const = 0;
    virtual bool saveToTextFile(const std::string& file) const = 0;

Fields

CPoint2D mean

The mean value.

mrpt::math::CMatrixDouble22 cov

The 2x2 covariance matrix.

Construction

CPoint2DPDFGaussian()

Default constructor.

CPoint2DPDFGaussian(const CPoint2D& init_Mean)

Constructor.

CPoint2DPDFGaussian(const CPoint2D& init_Mean, const mrpt::math::CMatrixDouble22& init_Cov)

Constructor.

Methods

void getMean(CPoint2D& p) const

Returns an estimate of the point, (the mean, or mathematical expectation of the PDF)

virtual std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const

Returns an estimate of the point covariance matrix (2x2 cov matrix) and the mean, both at once.

See also:

getMean

virtual void copyFrom(const CPoint2DPDF& o)

Copy operator, translating if necessary (for example, between particles and gaussian representations)

virtual bool saveToTextFile(const std::string& file) const

Save PDF’s particles to a text file, containing the 2D pose in the first line, then the covariance matrix in next 3 lines.

virtual void changeCoordinatesReference(const CPose3D& newReferenceBase)

this = p (+) this.

This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which “to project” the current pdf. Result PDF substituted the currently stored one in the object. Both the mean value and the covariance matrix are updated correctly.

void bayesianFusion(
    const CPoint2DPDFGaussian& p1,
    const CPoint2DPDFGaussian& p2
    )

Bayesian fusion of two points gauss.

distributions, then save the result in this object. The process is as follows:

  • (x1,S1): Mean and variance of the p1 distribution.

  • (x2,S2): Mean and variance of the p2 distribution.

  • (x,S): Mean and variance of the resulting distribution.

\(S = (S_1^{-1} + S_2^{-1})^{-1}\) \(x = S ( S_1^{-1} x_1 + S_2^{-1} x_2 )\)

double productIntegralWith(const CPoint2DPDFGaussian& p) const

Computes the “correspondence likelihood” of this PDF with another one: This is implemented as the integral from -inf to +inf of the product of both PDF.

The resulting number is >=0.

Parameters:

std::exception

On errors like covariance matrix with null determinant, etc…

See also:

productIntegralNormalizedWith

double productIntegralNormalizedWith(const CPoint2DPDFGaussian& p) const

Computes the “correspondence likelihood” of this PDF with another one: This is implemented as the integral from -inf to +inf of the product of both PDF.

The resulting number is in the range [0,1]. Note that the resulting value is in fact

\[exp( -\frac{1}{2} D^2 )\]

, with \(D^2\) being the square Mahalanobis distance between the two pdfs.

Parameters:

std::exception

On errors like covariance matrix with null determinant, etc…

See also:

productIntegralWith

void drawSingleSample(CPoint2D& outSample) const

Draw a sample from the pdf.

virtual void bayesianFusion(
    const CPoint2DPDF& p1,
    const CPoint2DPDF& p2,
    const double minMahalanobisDistToDrop = 0
    )

Bayesian fusion of two point distributions (product of two distributions->new distribution), then save the result in this object (WARNING: See implementing classes to see classes that can and cannot be mixtured!)

Parameters:

p1

The first distribution to fuse

p2

The second distribution to fuse

minMahalanobisDistToDrop

If set to different of 0, the result of very separate Gaussian modes (that will result in negligible components) in SOGs will be dropped to reduce the number of modes in the output.

double mahalanobisDistanceTo(const CPoint2DPDFGaussian& other) const

Returns the Mahalanobis distance from this PDF to another PDF, that is, it’s evaluation at (0,0,0)

double mahalanobisDistanceToPoint(const double x, const double y) const

Returns the Mahalanobis distance from this PDF to some point.