Go to the documentation of this file.
35 cout <<
"Histogram test:" << endl;
36 cout <<
"Should be 1: " << hist.getBinCount(0) << endl;
37 cout <<
"Should be 0.33: " << hist.getBinRatio(0)
53 win1.resize(400, 400);
56 std::vector<size_t>
v1(100000);
61 hist.getHistogramNormalized(
x,
y);
71 win2.resize(400, 400);
78 hist.getHistogramNormalized(
x,
y);
83 for (CVectorDouble::Index k = 0; k < y_real.size(); k++)
85 win2.plot(
x, y_real,
"k-",
"real");
93 win3.resize(400, 400);
100 hist.getHistogramNormalized(
x,
y);
102 win3.plot(
x,
y,
"b");
105 for (CVectorDouble::Index k = 0; k < y_real.size(); k++)
107 win3.plot(
x, y_real,
"k-",
"real");
114 win4.setPos(420, 430);
115 win4.resize(400, 400);
117 vector<CVectorDouble>
v1;
124 cov.fromMatlabStringFormat(
"[7.5 -7;-7 8]");
127 v1, 10000,
cov, &Mean);
132 mrpt::math::meanAndCov(
v1,m,
c);
133 cout <<
"Mean: " << m << endl;
134 cout <<
"Std: " << endl <<
c << endl;
139 for (
size_t i = 0; i <
v1.size(); i++)
145 win4.plot(
x,
y,
"b.3");
148 Mean[0], Mean[1],
cov, 3.0,
"k-2",
"99% ellipse",
true);
168 catch (std::exception& e)
170 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
175 printf(
"Untyped exception!!");
void TestRandomGenerators()
This class provides an easy way of computing histograms for unidimensional real valued variables.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
void drawGaussian1DVector(VEC &v, const double mean=0, const double std=1)
Fills the given vector with independent, 1D-normally distributed samples.
void drawGaussianMultivariateMany(VECTOR_OF_VECTORS &ret, size_t desiredSamples, const COVMATRIX &cov, const typename VECTOR_OF_VECTORS::value_type *mean=nullptr)
Generate a given number of multidimensional random samples according to a given covariance matrix.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample,...
double normalPDF(double x, double mu, double std)
Evaluates the univariate normal (Gaussian) distribution at a given point "x".
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
Classes for creating GUI windows for 2D and 3D visualization.
A numeric matrix of compile-time fixed size.
Create a GUI window and display plots with MATLAB-like interfaces and commands.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
This base provides a set of functions for maths stuff.
A namespace of pseudo-random numbers generators of diferent distributions.
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
void drawUniformVector(VEC &v, const double unif_min=0, const double unif_max=1)
Fills the given vector with independent, uniformly distributed samples.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |