Go to the documentation of this file.
9 #ifndef _MRPT_MONTE_CARLO_H_
10 #define _MRPT_MONTE_CARLO_H_
44 template <
typename T,
typename NUM,
typename OTHER>
52 Eigen::Matrix<NUM, Eigen::Dynamic, 1>
data;
55 template <
typename VEC>
59 template <
typename VEC>
64 template <
typename VEC>
69 template <
typename VEC1,
typename VEC2>
71 VEC1& vx, VEC2& vy,
const NUM
width = 1.0)
const
73 std::vector<double> vvx, vvy;
75 vx.assign(vvx.begin(), vvx.end());
76 vy.assign(vvy.begin(), vvy.end());
80 std::vector<double>& vx, std::vector<double>& vy,
81 const NUM
width = 1.0)
const
111 throw std::logic_error(
"Value generator function is not set.");
112 std::vector<T> baseData(N);
113 std::vector<NUM> errorData(N);
120 baseData.begin(), baseData.end(), errorData.begin(),
errorFun1);
126 throw std::logic_error(
127 "Experiment-related functions are not set.");
128 std::vector<OTHER> intermediate(N);
130 baseData.begin(), baseData.end(), intermediate.begin(),
133 for (
size_t i = 0; i < N; ++i)
134 errorData[i] =
errorFun2(baseData[i], intermediate[i]);
137 NUM
res = accumulate(errorData.begin(), errorData.end(), NUM(0)) /
144 std::vector<NUM> errorX,errorY;
146 wnd.
plot(errorX,errorY,
"b-",
"Plot1");
147 NUM maxVal=*std::max_element(errorY.begin(),errorY.end());
148 const std::vector<NUM> dx{
res,
res}, dy{.0, maxVal};
149 wnd.
plot(dx,dy,
"r-",
"Plot2");
EIGEN_STRONG_INLINE iterator begin()
This class provides an easy way of computing histograms for unidimensional real valued variables.
void getData(VEC &v1) const
A high-performance stopwatch, with typical resolution of nanoseconds.
NUM doExperiment(size_t N, double &time, bool showInWindow=false)
CStatisticalAnalyzer(const VEC &v1)
A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator.
Eigen::Matrix< NUM, Eigen::Dynamic, 1 > data
Montecarlo simulation for experiments in 1D.
NUM(* errorFun1)(const T &)
GLuint GLenum GLenum transform
void getDistribution(std::vector< double > &vx, std::vector< double > &vy, const NUM width=1.0) const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void plot(const std::vector< T1 > &x, const std::vector< T2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
Adds a new layer with a 2D plot based on two vectors of X and Y points, using a MATLAB-like syntax.
NUM(* errorFun2)(const T &, const OTHER &)
OTHER(* intermediateFun)(const T &)
mrpt::random::CRandomGenerator gen
double Tac() noexcept
Stops the stopwatch.
CHistogram createWithFixedWidth(double min, double max, double binWidth)
Constructor with a fixed bin width.
bool isOpen()
Returns false if the user has already closed the window.
GLsizei GLsizei GLenum GLenum const GLvoid * data
T(* valueGenerator)(mrpt::random::CRandomGenerator &)
void Tic() noexcept
Starts the stopwatch.
Create a GUI window and display plots with MATLAB-like interfaces and commands.
void getHistogram(std::vector< double > &x, std::vector< double > &hits) const
Returns the list of bin centers & hit counts.
void add(const double x)
Add an element to the histogram.
void getDistribution(VEC1 &vx, VEC2 &vy, const NUM width=1.0) const
void setData(const VEC &v1)
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 | |