82 inline std::vector<std::string>
DistributionTypeNames () {
return {
"Constant",
"Uniform",
"Gaussian",
"Poisson",
"Custom",
"Interpolated",
"Discrete"}; }
106 inline std::vector<DistributionType>
DistributionTypeCast (
const std::vector<int> distributionTypeIndeces) {
return castFromValues<DistributionType>(distributionTypeIndeces); }
181 {
return this->
operator()(xx)*pow(xx, order); }
414 void set_discrete_values (
const std::vector<double> discrete_values,
const std::vector<double> weights,
const int seed=1);
427 void set_binned_distribution (
const std::vector<double> var,
const std::vector<double> dist,
const std::string interpolationType=
"Spline",
const int seed=1);
493 double sample (
const int seed);
550 std::vector<double>
moments ();
600 void get_distribution (std::vector<double> &xx, std::vector<double> &fx, std::vector<double> &err,
const std::vector<double> FF,
const std::vector<double> WW,
const int nbin,
const bool linear=
true,
const std::string file_out=
par::defaultString,
const double fact=1.,
const double V1=
par::defaultDouble,
const double V2=
par::defaultDouble,
const bool bin_type=
true,
const bool conv=
false,
const double sigma=0.);
Useful generic functions.
The class CombinedDistribution.
double m_xmin
the distribution lower limit
void set_gaussian_distribution(const double mean, const double sigma, const int seed=1)
set normal distribution
double m_log_distribution_normalization
the natural log of distribution normalization
double get_seed() const
return the private member m_seed
void set_seed(const int seed)
set distribution seed
double m_central_moments_integrator(const double xx, const unsigned int order)
integrand of the central moments of the distribution
void set_custom_distribution(const distribution_func func, const std::shared_ptr< void > distribution_fixed_pars, const std::vector< double > distribution_pars, const int seed=1)
set a custom distribution
void m_set_distribution_normalization()
set distribution normalization
std::shared_ptr< void > m_distribution_func_fixed_pars
void pointer for the distribution function
double m_xmax
the distribution upper limit
std::vector< double > m_distribution_func_pars
the parameters of the distribution function
DistributionType distributionType() const
return the distribution type
std::shared_ptr< random::RandomNumbers > m_distribution_random
the distribution random generator
double m_mean
the distribution mean
distribution_func m_func
the probability distribution function
double operator()(double xx)
evaluate distribution
double xmax() const
return the private member m_xmax
double get_mean() const
return the private member m_mean
void set_poisson_distribution(const double mean, const int seed=1)
set poisson distribution
double mean()
return the mean value of the distribution
double m_moments_integrator(const double xx, const unsigned int order)
integrand of the moments distribution
double mode()
return the distribution mode
void set_constant_distribution(const double value)
set a constant distribution
Distribution()
default constructor
DistributionType m_distributionType
the type of distribution
void set_limits(const double xmin, const double xmax)
set the distribution limits
double log_distribution(double xx)
evaluate log-distribution
double m_distribution_normalization
the distribution normalization
~Distribution()=default
default destructor
int m_seed
the distribution seed
double kurtosis()
return the kurtosis of the distribution
std::vector< double > moments()
return the moments of the distribution distribution
double distribution_range() const
the distribution range
double median()
return the median of the distibution
double variance()
return the standard deviation of the distribution
double skewness()
return the skewness of the distribution
double sample() const
sample a value from the distribution
double get_sigma() const
return the private member m_sigma
void set_uniform_distribution(const double xmin, const double xmax, const int seed=1)
set an uniform distribution with input limits and seed
void set_discrete_values(const std::vector< double > discrete_values, const std::vector< double > weights, const int seed=1)
set discrete distribution values and weights
double std()
return the standard deviation of the distribution
void get_distribution(std::vector< double > &xx, std::vector< double > &fx, std::vector< double > &err, const std::vector< double > FF, const std::vector< double > WW, const int nbin, const bool linear=true, const std::string file_out=par::defaultString, const double fact=1., const double V1=par::defaultDouble, const double V2=par::defaultDouble, const bool bin_type=true, const bool conv=false, const double sigma=0.)
derive and store the number distribution of a given std::vector
double xmin() const
return the private member m_xmin
double m_percentile_integrator(const double xx)
integrand of the percentile of the distribution
double m_variance
the distribution variance
void set_binned_distribution(const std::vector< double > var, const std::vector< double > dist, const std::string interpolationType="Spline", const int seed=1)
set discrete distribution values and weights
bool isIncluded(const double value) const
check if a value is included in the distribution limits
double m_sigma
the distribution standard deviation
double percentile(const unsigned int i)
return the i-th percentile of the distribution
std::vector< double > sample_vector(const int nvalues)
sample values from the distribution
static const std::string defaultString
default std::string value
static const double defaultDouble
default double value
DistributionType
the distribution type
@ _Interpolated_
User defined Tabulated Function.
@ _Custom_
Custom function.
@ _Constant_
Constant function.
@ _Uniform_
Identity function.
@ _Gaussian_
Gaussian function.
@ _Poisson_
Poisson function.
@ _Discrete_
Discrete distribution.
std::vector< std::string > DistributionTypeNames()
return a vector containing the DistributionType names
DistributionType DistributionTypeCast(const int distributionTypeIndex)
cast an enum of type DistributionType from its index
The global namespace of the CosmoBolognaLib
std::string conv(const T val, const char *fact)
convert a number to a std::string
std::function< double(double, std::shared_ptr< void >, std::vector< double >)> distribution_func
generic distribution function