1 #ifndef _utl_RandomSamplerFromCDF_h_
2 #define _utl_RandomSamplerFromCDF_h_
9 #include <utl/VRandomSampler.h>
14 class RandomSamplerFromPDF;
15 class TabulatedFunction;
45 const std::string& independentVariableName,
46 const double min,
const double max,
const int bins)
47 {
SetFunction(
function, independentVariableName, min, max, bins); }
50 const double min,
const double max,
const int bins)
65 const std::vector<double>&
GetCDFX()
const {
return fX; }
67 const std::vector<double>&
GetCDFY()
const {
return fY; }
71 const std::string& independentVariableName,
72 const double min,
const double max,
const int bins);
75 {
return std::distance(
fY.begin(), std::lower_bound(
fY.begin(),
fY.end(), y)); }
81 std::vector<double>
fX;
82 std::vector<double>
fY;
const std::vector< double > & GetCDFY() const
Class to hold collection (x,y) points and provide interpolation between them.
int GetIndex(const double y) const
RandomSamplerFromCDF(const std::string &function, const std::string &independentVariableName, const double min, const double max, const int bins)
Construct the CDF from a function defined by a string.
double GetInverseCDF(const double y) const
const std::vector< double > & GetCDFX() const
RandomSamplerFromCDF(const std::string &function, const double min, const double max, const int bins)
void SetFunction(const std::string &function, const std::string &independentVariableName, const double min, const double max, const int bins)
RandomSamplerFromCDF(const std::vector< double > &x, const std::vector< double > &y)
Construct using a CDF defined by X and Y vectors.
virtual double MapRandom(const double rand) const
virtual ~RandomSamplerFromCDF()
Class to shoot random numbers given by a user-defined distribution function.