MRPT  1.9.9
CPointPDFSOG.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "poses-precomp.h" // Precompiled headers
11 
16 #include <mrpt/poses/CPose3D.h>
17 #include <mrpt/poses/CPosePDF.h>
18 #include <mrpt/random.h>
20 #include <mrpt/system/os.h>
21 #include <Eigen/Dense>
22 
23 using namespace mrpt::poses;
24 using namespace mrpt::math;
25 
26 using namespace mrpt::bayes;
27 using namespace mrpt::random;
28 using namespace mrpt::system;
29 using namespace std;
30 
32 
33 /*---------------------------------------------------------------
34  Constructor
35  ---------------------------------------------------------------*/
36 CPointPDFSOG::CPointPDFSOG(size_t nModes) : m_modes(nModes) {}
37 /*---------------------------------------------------------------
38  clear
39  ---------------------------------------------------------------*/
40 void CPointPDFSOG::clear() { m_modes.clear(); }
41 /*---------------------------------------------------------------
42  Resize
43  ---------------------------------------------------------------*/
44 void CPointPDFSOG::resize(const size_t N) { m_modes.resize(N); }
45 /*---------------------------------------------------------------
46  getMean
47  Returns an estimate of the pose, (the mean, or mathematical expectation of the
48  PDF)
49  ---------------------------------------------------------------*/
51 {
52  size_t N = m_modes.size();
53  double X = 0, Y = 0, Z = 0;
54 
55  if (N)
56  {
57  CListGaussianModes::const_iterator it;
58  double sumW = 0;
59 
60  for (it = m_modes.begin(); it != m_modes.end(); ++it)
61  {
62  double w;
63  sumW += w = exp(it->log_w);
64  X += it->val.mean.x() * w;
65  Y += it->val.mean.y() * w;
66  Z += it->val.mean.z() * w;
67  }
68  if (sumW > 0)
69  {
70  X /= sumW;
71  Y /= sumW;
72  Z /= sumW;
73  }
74  }
75 
76  p.x(X);
77  p.y(Y);
78  p.z(Z);
79 }
80 
81 std::tuple<CMatrixDouble33, CPoint3D> CPointPDFSOG::getCovarianceAndMean() const
82 {
83  size_t N = m_modes.size();
84 
85  CMatrixDouble33 estCov;
86  CPoint3D p;
87  getMean(p);
88  estCov.setZero();
89 
90  if (N)
91  {
92  // 1) Get the mean:
93  double sumW = 0;
94  auto estMean = CMatrixDouble31(p);
95 
96  CListGaussianModes::const_iterator it;
97 
98  for (it = m_modes.begin(); it != m_modes.end(); ++it)
99  {
100  double w;
101  sumW += w = exp(it->log_w);
102 
103  auto estMean_i = CMatrixDouble31(it->val.mean);
104  estMean_i -= estMean;
105 
106  auto partCov =
107  CMatrixDouble33(estMean_i.asEigen() * estMean_i.transpose());
108  partCov += it->val.cov;
109  partCov *= w;
110  estCov += partCov;
111  }
112 
113  if (sumW != 0) estCov *= (1.0 / sumW);
114  }
115 
116  return {estCov, p};
117 }
118 
121 {
122  uint32_t N = m_modes.size();
123  out << N;
124  for (const auto& m : m_modes)
125  {
126  out << m.log_w;
127  out << m.val.mean;
129  }
130 }
133 {
134  switch (version)
135  {
136  case 0:
137  case 1:
138  {
139  uint32_t N;
140  in >> N;
141  this->resize(N);
142  for (auto& m : m_modes)
143  {
144  in >> m.log_w;
145 
146  // In version 0, weights were linear!!
147  if (version == 0) m.log_w = log(max(1e-300, m.log_w));
148 
149  in >> m.val.mean;
151  }
152  }
153  break;
154  default:
156  };
157 }
158 
160 {
161  MRPT_START
162 
163  if (this == &o) return; // It may be used sometimes
164 
166  {
167  m_modes = static_cast<const CPointPDFSOG*>(&o)->m_modes;
168  }
169  else
170  {
171  // Approximate as a mono-modal gaussian pdf:
172  this->resize(1);
173  m_modes[0].log_w = 0;
174  o.getCovarianceAndMean(m_modes[0].val.cov, m_modes[0].val.mean);
175  }
176 
177  MRPT_END
178 }
179 
180 /*---------------------------------------------------------------
181  saveToTextFile
182  ---------------------------------------------------------------*/
184 {
185  FILE* f = os::fopen(file.c_str(), "wt");
186  if (!f) return false;
187 
188  for (const auto& m_mode : m_modes)
189  os::fprintf(
190  f, "%e %e %e %e %e %e %e %e %e %e\n", exp(m_mode.log_w),
191  m_mode.val.mean.x(), m_mode.val.mean.y(), m_mode.val.mean.z(),
192  m_mode.val.cov(0, 0), m_mode.val.cov(1, 1), m_mode.val.cov(2, 2),
193  m_mode.val.cov(0, 1), m_mode.val.cov(0, 2), m_mode.val.cov(1, 2));
194  os::fclose(f);
195  return true;
196 }
197 
198 /*---------------------------------------------------------------
199  changeCoordinatesReference
200  ---------------------------------------------------------------*/
202 {
203  for (auto& m : m_modes) m.val.changeCoordinatesReference(newReferenceBase);
204 }
205 
206 /*---------------------------------------------------------------
207  drawSingleSample
208  ---------------------------------------------------------------*/
210 {
211  MRPT_START
212 
213  ASSERT_(m_modes.size() > 0);
214 
215  // 1st: Select a mode with a probability proportional to its weight:
216  vector<double> logWeights(m_modes.size());
217  vector<size_t> outIdxs;
218  vector<double>::iterator itW;
219  CListGaussianModes::const_iterator it;
220  for (it = m_modes.begin(), itW = logWeights.begin(); it != m_modes.end();
221  ++it, ++itW)
222  *itW = it->log_w;
223 
224  CParticleFilterCapable::computeResampling(
225  CParticleFilter::prMultinomial, // Resampling algorithm
226  logWeights, // input: log weights
227  outIdxs // output: indexes
228  );
229 
230  // we need just one: take the first (arbitrary)
231  size_t selectedIdx = outIdxs[0];
232  ASSERT_(selectedIdx < m_modes.size());
233  const CPointPDFGaussian* selMode = &m_modes[selectedIdx].val;
234 
235  // 2nd: Draw a position from the selected Gaussian:
236  CVectorDouble vec;
237  getRandomGenerator().drawGaussianMultivariate(vec, selMode->cov);
238 
239  ASSERT_(vec.size() == 3);
240  outSample.x(selMode->mean.x() + vec[0]);
241  outSample.y(selMode->mean.y() + vec[1]);
242  outSample.z(selMode->mean.z() + vec[2]);
243 
244  MRPT_END
245 }
246 
247 /*---------------------------------------------------------------
248  bayesianFusion
249  ---------------------------------------------------------------*/
251  const CPointPDF& p1_, const CPointPDF& p2_,
252  const double minMahalanobisDistToDrop)
253 {
254  MRPT_START
255 
256  // p1: CPointPDFSOG, p2: CPosePDFGaussian:
257 
260 
261  const auto* p1 = static_cast<const CPointPDFSOG*>(&p1_);
262  const auto* p2 = static_cast<const CPointPDFSOG*>(&p2_);
263 
264  // Compute the new kernel means, covariances, and weights after multiplying
265  // to the Gaussian "p2":
266  CPointPDFGaussian auxGaussianProduct, auxSOG_Kernel_i;
267 
268  float minMahalanobisDistToDrop2 = square(minMahalanobisDistToDrop);
269 
270  this->m_modes.clear();
271  bool is2D =
272  false; // to detect & avoid errors in 3x3 matrix inversions of range=2.
273 
274  for (const auto& m : p1->m_modes)
275  {
276  CMatrixDouble33 c = m.val.cov;
277 
278  // Is a 2D covariance??
279  if (c(2, 2) == 0)
280  {
281  is2D = true;
282  c(2, 2) = 1;
283  }
284 
285  ASSERT_(c(0, 0) != 0 && c(0, 0) != 0);
286 
287  const CMatrixDouble33 covInv = c.inverse_LLt();
288 
289  Eigen::Vector3d eta = covInv * CMatrixDouble31(m.val.mean);
290 
291  // Normal distribution canonical form constant:
292  // See: http://www-static.cc.gatech.edu/~wujx/paper/Gaussian.pdf
293  double a = -0.5 * (3 * log(M_2PI) - log(covInv.det()) +
294  (eta.transpose() * c.asEigen() * eta)(0, 0));
295 
296  for (const auto& m2 : p2->m_modes)
297  {
298  auxSOG_Kernel_i = m2.val;
299  if (auxSOG_Kernel_i.cov(2, 2) == 0)
300  {
301  auxSOG_Kernel_i.cov(2, 2) = 1;
302  is2D = true;
303  }
304  ASSERT_(
305  auxSOG_Kernel_i.cov(0, 0) > 0 && auxSOG_Kernel_i.cov(1, 1) > 0);
306 
307  // Should we drop this product term??
308  bool reallyComputeThisOne = true;
309  if (minMahalanobisDistToDrop > 0)
310  {
311  // Approximate (fast) mahalanobis distance (square):
312  float mahaDist2;
313 
314  float stdX2 = max(auxSOG_Kernel_i.cov(0, 0), m.val.cov(0, 0));
315  mahaDist2 =
316  square(auxSOG_Kernel_i.mean.x() - m.val.mean.x()) / stdX2;
317 
318  float stdY2 = max(auxSOG_Kernel_i.cov(1, 1), m.val.cov(1, 1));
319  mahaDist2 +=
320  square(auxSOG_Kernel_i.mean.y() - m.val.mean.y()) / stdY2;
321 
322  if (!is2D)
323  {
324  float stdZ2 =
325  max(auxSOG_Kernel_i.cov(2, 2), m.val.cov(2, 2));
326  mahaDist2 +=
327  square(auxSOG_Kernel_i.mean.z() - m.val.mean.z()) /
328  stdZ2;
329  }
330 
331  reallyComputeThisOne = mahaDist2 < minMahalanobisDistToDrop2;
332  }
333 
334  if (reallyComputeThisOne)
335  {
336  auxGaussianProduct.bayesianFusion(auxSOG_Kernel_i, m.val);
337 
338  // ----------------------------------------------------------------------
339  // The new weight is given by:
340  //
341  // w'_i = w_i * exp( a + a_i - a' )
342  //
343  // a = -1/2 ( dimensionality * log(2pi) - log(det(Cov^-1))
344  // + (Cov^-1 * mu)^t * Cov^-1 * (Cov^-1 * mu) )
345  //
346  // ----------------------------------------------------------------------
347  TGaussianMode newKernel;
348 
349  newKernel.val = auxGaussianProduct; // Copy mean & cov
350 
351  CMatrixDouble33 covInv_i = auxSOG_Kernel_i.cov.inverse_LLt();
352  Eigen::Vector3d eta_i =
353  CMatrixDouble31(auxSOG_Kernel_i.mean).asEigen();
354  eta_i = covInv_i.asEigen() * eta_i;
355 
356  CMatrixDouble33 new_covInv_i = newKernel.val.cov.inverse_LLt();
357  Eigen::Vector3d new_eta_i =
358  CMatrixDouble31(newKernel.val.mean).asEigen();
359  new_eta_i = new_covInv_i.asEigen() * new_eta_i;
360 
361  double a_i =
362  -0.5 * (3 * log(M_2PI) - log(new_covInv_i.det()) +
363  (eta_i.transpose() * auxSOG_Kernel_i.cov.asEigen() *
364  eta_i)(0, 0));
365  double new_a_i =
366  -0.5 * (3 * log(M_2PI) - log(new_covInv_i.det()) +
367  (new_eta_i.transpose() *
368  newKernel.val.cov.asEigen() * new_eta_i)(0, 0));
369 
370  newKernel.log_w = m.log_w + m2.log_w + a + a_i - new_a_i;
371 
372  // Fix 2D case:
373  if (is2D) newKernel.val.cov(2, 2) = 0;
374 
375  // Add to the results (in "this") the new kernel:
376  this->m_modes.push_back(newKernel);
377  } // end if reallyComputeThisOne
378  } // end for it2
379 
380  } // end for it1
381 
382  normalizeWeights();
383 
384  MRPT_END
385 }
386 
387 /*---------------------------------------------------------------
388  enforceCovSymmetry
389  ---------------------------------------------------------------*/
391 {
392  MRPT_START
393  // Differences, when they exist, appear in the ~15'th significant
394  // digit, so... just take one of them arbitrarily!
395  for (auto& m_mode : m_modes)
396  {
397  m_mode.val.cov(0, 1) = m_mode.val.cov(1, 0);
398  m_mode.val.cov(0, 2) = m_mode.val.cov(2, 0);
399  m_mode.val.cov(1, 2) = m_mode.val.cov(2, 1);
400  }
401 
402  MRPT_END
403 }
404 
405 /*---------------------------------------------------------------
406  normalizeWeights
407  ---------------------------------------------------------------*/
409 {
410  MRPT_START
411 
412  if (!m_modes.size()) return;
413 
414  CListGaussianModes::iterator it;
415  double maxW = m_modes[0].log_w;
416  for (it = m_modes.begin(); it != m_modes.end(); ++it)
417  maxW = max(maxW, it->log_w);
418 
419  for (it = m_modes.begin(); it != m_modes.end(); ++it) it->log_w -= maxW;
420 
421  MRPT_END
422 }
423 
424 /*---------------------------------------------------------------
425  ESS
426  ---------------------------------------------------------------*/
427 double CPointPDFSOG::ESS() const
428 {
429  MRPT_START
430  CListGaussianModes::const_iterator it;
431  double cum = 0;
432 
433  /* Sum of weights: */
434  double sumLinearWeights = 0;
435  for (it = m_modes.begin(); it != m_modes.end(); ++it)
436  sumLinearWeights += exp(it->log_w);
437 
438  /* Compute ESS: */
439  for (it = m_modes.begin(); it != m_modes.end(); ++it)
440  cum += square(exp(it->log_w) / sumLinearWeights);
441 
442  if (cum == 0)
443  return 0;
444  else
445  return 1.0 / (m_modes.size() * cum);
446  MRPT_END
447 }
448 
449 /*---------------------------------------------------------------
450  evaluatePDFInArea
451  ---------------------------------------------------------------*/
453  float x_min, float x_max, float y_min, float y_max, float resolutionXY,
454  float z, CMatrixD& outMatrix, bool sumOverAllZs)
455 {
456  MRPT_START
457 
458  ASSERT_(x_max > x_min);
459  ASSERT_(y_max > y_min);
460  ASSERT_(resolutionXY > 0);
461 
462  const auto Nx = (size_t)ceil((x_max - x_min) / resolutionXY);
463  const auto Ny = (size_t)ceil((y_max - y_min) / resolutionXY);
464  outMatrix.setSize(Ny, Nx);
465 
466  for (size_t i = 0; i < Ny; i++)
467  {
468  const float y = y_min + i * resolutionXY;
469  for (size_t j = 0; j < Nx; j++)
470  {
471  float x = x_min + j * resolutionXY;
472  outMatrix(i, j) = evaluatePDF(CPoint3D(x, y, z), sumOverAllZs);
473  }
474  }
475 
476  MRPT_END
477 }
478 
479 /*---------------------------------------------------------------
480  evaluatePDF
481  ---------------------------------------------------------------*/
482 double CPointPDFSOG::evaluatePDF(const CPoint3D& x, bool sumOverAllZs) const
483 {
484  if (!sumOverAllZs)
485  {
486  // Normal evaluation:
487  auto X = CMatrixDouble31(x);
488  double ret = 0;
489 
490  CMatrixDouble31 MU;
491 
492  for (const auto& m_mode : m_modes)
493  {
494  MU = CMatrixDouble31(m_mode.val.mean);
495  ret += exp(m_mode.log_w) * math::normalPDF(X, MU, m_mode.val.cov);
496  }
497 
498  return ret;
499  }
500  else
501  {
502  // Only X,Y:
503  CMatrixD X(2, 1), MU(2, 1), COV(2, 2);
504  double ret = 0;
505 
506  X(0, 0) = x.x();
507  X(1, 0) = x.y();
508 
509  for (const auto& m_mode : m_modes)
510  {
511  MU(0, 0) = m_mode.val.mean.x();
512  MU(1, 0) = m_mode.val.mean.y();
513 
514  COV(0, 0) = m_mode.val.cov(0, 0);
515  COV(1, 1) = m_mode.val.cov(1, 1);
516  COV(0, 1) = COV(1, 0) = m_mode.val.cov(0, 1);
517 
518  ret += exp(m_mode.log_w) * math::normalPDF(X, MU, COV);
519  }
520 
521  return ret;
522  }
523 }
524 
525 /*---------------------------------------------------------------
526  getMostLikelyMode
527  ---------------------------------------------------------------*/
529 {
530  if (this->empty())
531  {
532  outVal = CPointPDFGaussian();
533  }
534  else
535  {
536  auto it_best = m_modes.end();
537  for (auto it = m_modes.begin(); it != m_modes.end(); ++it)
538  if (it_best == m_modes.end() || it->log_w > it_best->log_w)
539  it_best = it;
540 
541  outVal = it_best->val;
542  }
543 }
544 
545 /*---------------------------------------------------------------
546  getAs3DObject
547  ---------------------------------------------------------------*/
548 // void CPointPDFSOG::getAs3DObject( mrpt::opengl::CSetOfObjects::Ptr &outObj
549 // )
550 // const
551 //{
552 // // For each gaussian node
553 // for (CListGaussianModes::const_iterator it = m_modes.begin(); it!=
554 // m_modes.end();++it)
555 // {
556 // opengl::CEllipsoid::Ptr obj =
557 // std::make_shared<opengl::CEllipsoid>();
558 //
559 // obj->setPose( it->val.mean);
560 // obj->setCovMatrix(it->val.cov, it->val.cov(2,2)==0 ? 2:3);
561 //
562 // obj->setQuantiles(3);
563 // obj->enableDrawSolid3D(false);
564 // obj->setColor(1,0,0, 0.5);
565 //
566 // outObj->insert( obj );
567 // } // end for each gaussian node
568 //}
A namespace of pseudo-random numbers generators of diferent distributions.
void serializeSymmetricMatrixTo(MAT &m, mrpt::serialization::CArchive &out)
Binary serialization of symmetric matrices, saving the space of duplicated values.
#define MRPT_START
Definition: exceptions.h:241
GLdouble GLdouble z
Definition: glext.h:3879
This class is a "CSerializable" wrapper for "CMatrixDynamic<double>".
Definition: CMatrixD.h:23
#define M_2PI
Definition: common.h:58
void getMean(CPoint3D &mean_point) const override
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:275
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
CPoint3D mean
The mean value.
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
void resize(const size_t N)
Resize the number of SOG modes.
Declares a class that represents a Probability Density function (PDF) of a 3D point ...
Definition: CPointPDFSOG.h:33
The struct for each mode:
Definition: CPointPDFSOG.h:40
size_type size() const
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
void clear()
Clear all the gaussian modes.
void drawSingleSample(CPoint3D &outSample) const override
Draw a sample from the pdf.
STL namespace.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4199
unsigned char uint8_t
Definition: rptypes.h:44
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
T square(const T x)
Inline function for the square of a number.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
void bayesianFusion(const CPointPDFGaussian &p1, const CPointPDFGaussian &p2)
Bayesian fusion of two points gauss.
CMatrixFixed< double, 3, 3 > CMatrixDouble33
Definition: CMatrixFixed.h:352
This base provides a set of functions for maths stuff.
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:89
CMatrixFixed< double, 3, 1 > CMatrixDouble31
Definition: CMatrixFixed.h:357
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
const GLubyte * c
Definition: glext.h:6406
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
void deserializeSymmetricMatrixFrom(MAT &m, mrpt::serialization::CArchive &in)
Binary serialization of symmetric matrices, saving the space of duplicated values.
int val
Definition: mrpt_jpeglib.h:957
void normalizeWeights()
Normalize the weights in m_modes such as the maximum log-weight is 0.
Scalar det() const
Determinant of matrix.
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:143
Derived inverse_LLt() const
Returns the inverse of a symmetric matrix using LLt.
std::tuple< cov_mat_t, type_value > getCovarianceAndMean() const override
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean...
GLsizei const GLchar ** string
Definition: glext.h:4116
A class used to store a 3D point.
Definition: CPoint3D.h:31
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:38
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
bool empty() const
Definition: ts_hash_map.h:190
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
Definition: os.cpp:410
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
void copyFrom(const CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
void drawGaussianMultivariate(std::vector< T > &out_result, const MATRIX &cov, const std::vector< T > *mean=nullptr)
Generate multidimensional random samples according to a given covariance matrix.
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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:84
This file implements matrix/vector text and binary serialization.
double ESS() const
Computes the "Effective sample size" (typical measure for Particle Filters), applied to the weights o...
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
#define MRPT_END
Definition: exceptions.h:245
GLuint in
Definition: glext.h:7391
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
Definition: CMatrixFixed.h:251
void evaluatePDFInArea(float x_min, float x_max, float y_min, float y_max, float resolutionXY, float z, mrpt::math::CMatrixD &outMatrix, bool sumOverAllZs=false)
Evaluates the PDF within a rectangular grid and saves the result in a matrix (each row contains value...
GLenum GLint GLint y
Definition: glext.h:3542
void getMostLikelyMode(CPointPDFGaussian &outVal) const
Return the Gaussian mode with the highest likelihood (or an empty Gaussian if there are no modes in t...
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:257
GLenum GLint x
Definition: glext.h:3542
void enforceCovSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
unsigned __int32 uint32_t
Definition: rptypes.h:50
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:36
double normalPDF(double x, double mu, double std)
Evaluates the univariate normal (Gaussian) distribution at a given point "x".
Definition: math.cpp:34
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
GLubyte GLubyte GLubyte a
Definition: glext.h:6372
GLfloat GLfloat p
Definition: glext.h:6398
double evaluatePDF(const CPoint3D &x, bool sumOverAllZs) const
Evaluates the PDF at a given point.
bool saveToTextFile(const std::string &file) const override
Save the density to a text file, with the following format: There is one row per Gaussian "mode"...
A gaussian distribution for 3D points.
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double minMahalanobisDistToDrop=0) override
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!)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019