10 #include <gtest/gtest.h> 14 #include <Eigen/Dense> 21 const double eps = 1e-12;
23 TEST(distributions, normalPDF_1d)
31 TEST(distributions, normalPDF_vector)
33 const double cov_vals[3 * 3] = {4.0, 2.0, 1.0, 2.0, 3.0,
35 const double x1_vals[3] = {1.0, 0.0, 0.0};
36 const double x2_vals[3] = {1.0, 2.0, 3.0};
44 normalPDF(x0, x0, COV), 0.02592116832548877620,
47 normalPDF(x2, x2, COV), 0.02592116832548877620,
51 normalPDF(x1, x0, COV), 0.02061240910323311470,
54 normalPDF(x2, x0, COV), 0.00008423820480102986,
58 normalPDF(x1, COV), 0.02061240910323311470,
61 normalPDF(x2, COV), 0.00008423820480102986,
67 const double eps2 = 1e-7;
69 EXPECT_NEAR(std::erfc(0), 1,
eps);
70 EXPECT_NEAR(std::erfc(1), 0.157299207050285, eps2);
71 EXPECT_NEAR(std::erfc(2), 0.004677734981047, eps2);
76 const double eps2 = 1e-7;
78 EXPECT_NEAR(std::erf(0), 0,
eps);
79 EXPECT_NEAR(std::erf(1), 0.842700792949715, eps2);
80 EXPECT_NEAR(std::erf(2), 0.995322265018953, eps2);
110 const double eps2 = 1e-7;
162 const double cov_vals[3 * 3] = {0.00393682, -6.11165e-07, -8.62169e-05,
163 -6.11165e-07, 7.44917e-05, -1.17274e-07,
164 -8.62169e-05, -1.17274e-07, 0.000108955};
167 const double x_vals[3] = {0.0135442, 0.00504134, -0.000452334};
170 double out_maha2, out_ml;
173 EXPECT_NEAR(out_maha2, 0.388264, 1e-4);
174 EXPECT_NEAR(out_ml, 9.14118, 1e-4);
A namespace of pseudo-random numbers generators of diferent distributions.
TEST(distributions, normalPDF_1d)
double normalCDF(double p)
Evaluates the Gaussian cumulative density function.
This base provides a set of functions for maths stuff.
std::pair< double, double > noncentralChi2PDF_CDF(unsigned int degreesOfFreedom, double noncentrality, double arg, double eps=1e-7)
Returns the 'exact' PDF (first) and CDF (second) of a Non-central chi-squared probability distributio...
void mahalanobisDistance2AndLogPDF(const VECLIKE &diff_mean, const MATRIXLIKE &cov, T &maha2_out, T &log_pdf_out)
Computes both, the logarithm of the PDF and the square Mahalanobis distance between a point (given by...
double chi2PDF(unsigned int degreesOfFreedom, double arg, double accuracy=1e-7)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double chi2inv(double P, unsigned int dim=1)
The "quantile" of the Chi-Square distribution, for dimension "dim" and probability 0<P<1 (the inverse...
double normalPDF(double x, double mu, double std)
Evaluates the univariate normal (Gaussian) distribution at a given point "x".