41 template <
typename T,
typename NUM,
typename OTHER>
52 template <
typename VEC>
56 template <
typename VEC>
59 data.assign(v1.begin(), v1.end());
61 template <
typename VEC>
66 template <
typename VEC1,
typename VEC2>
68 VEC1& vx, VEC2& vy,
const NUM width = 1.0)
const 70 std::vector<double> vvx, vvy;
72 vx.assign(vvx.begin(), vvx.end());
73 vy.assign(vvy.begin(), vvy.end());
77 std::vector<double>& vx, std::vector<double>& vy,
78 const NUM width = 1.0)
const 81 0, *max_element(
data.begin(),
data.end()), width));
83 hist.getHistogram(vx, vy);
107 throw std::logic_error(
"Value generator function is not set.");
108 std::vector<T> baseData(N);
109 std::vector<NUM> errorData(N);
116 baseData.begin(), baseData.end(), errorData.begin(),
errorFun1);
122 throw std::logic_error(
123 "Experiment-related functions are not set.");
124 std::vector<OTHER> intermediate(N);
126 baseData.begin(), baseData.end(), intermediate.begin(),
129 for (
size_t i = 0; i < N; ++i)
130 errorData[i] =
errorFun2(baseData[i], intermediate[i]);
133 NUM res = accumulate(errorData.begin(), errorData.end(), NUM(0)) /
140 std::vector<NUM> errorX,errorY;
142 wnd.
plot(errorX,errorY,
"b-",
"Plot1");
143 NUM maxVal=*std::max_element(errorY.begin(),errorY.end());
144 const std::vector<NUM> dx{res, res}, dy{.0, maxVal};
145 wnd.
plot(dx,dy,
"r-",
"Plot2");
double Tac() noexcept
Stops the stopwatch.
void setData(const VEC &v1)
This class provides an easy way of computing histograms for unidimensional real valued variables...
CStatisticalAnalyzer(const VEC &v1)
void getDistribution(VEC1 &vx, VEC2 &vy, const NUM width=1.0) const
Create a GUI window and display plots with MATLAB-like interfaces and commands.
NUM doExperiment(size_t N, double &time, bool showInWindow=false)
T(* valueGenerator)(mrpt::random::CRandomGenerator &)
A high-performance stopwatch, with typical resolution of nanoseconds.
A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator...
This base provides a set of functions for maths stuff.
void add(const double x)
Add an element to the histogram.
void getData(VEC &v1) const
Eigen::Matrix< NUM, Eigen::Dynamic, 1 > data
bool isOpen()
Returns false if the user has already closed the window.
OTHER(* intermediateFun)(const T &)
NUM(* errorFun1)(const T &)
void getDistribution(std::vector< double > &vx, std::vector< double > &vy, const NUM width=1.0) const
mrpt::random::CRandomGenerator gen
const_iterator end() const
const_iterator begin() const
Montecarlo simulation for experiments in 1D.
void plot(const VEC1 &x, const VEC2 &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...
void Tic() noexcept
Starts the stopwatch.
CHistogram createWithFixedWidth(double min, double max, double binWidth)
Constructor with a fixed bin width.
NUM(* errorFun2)(const T &, const OTHER &)