![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class CombinedDistribution. More...
#include "Headers/Distribution.h"
Public Member Functions | |
DistributionType | distributionType () const |
return the distribution type More... | |
double | operator() (double xx) |
evaluate distribution More... | |
double | log_distribution (double xx) |
evaluate log-distribution More... | |
void | set_seed (const int seed) |
set distribution seed More... | |
void | set_limits (const double xmin, const double xmax) |
set the distribution limits More... | |
void | set_constant_distribution (const double value) |
set a constant distribution More... | |
void | set_uniform_distribution (const double xmin, const double xmax, const int seed=1) |
set an uniform distribution with input limits and seed More... | |
void | set_gaussian_distribution (const double mean, const double sigma, const int seed=1) |
set normal distribution More... | |
void | set_poisson_distribution (const double mean, const int seed=1) |
set poisson distribution More... | |
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 More... | |
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 More... | |
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 More... | |
double | xmin () const |
return the private member m_xmin More... | |
double | xmax () const |
return the private member m_xmax More... | |
double | get_mean () const |
return the private member m_mean More... | |
double | get_sigma () const |
return the private member m_sigma More... | |
double | get_seed () const |
return the private member m_seed More... | |
double | distribution_range () const |
the distribution range More... | |
bool | isIncluded (const double value) const |
check if a value is included in the distribution limits More... | |
double | sample () const |
sample a value from the distribution More... | |
double | sample (const int seed) |
sample a value from the distribution More... | |
std::vector< double > | sample_vector (const int nvalues) |
sample values from the distribution More... | |
double | mean () |
return the mean value of the distribution More... | |
double | variance () |
return the standard deviation of the distribution More... | |
double | std () |
return the standard deviation of the distribution More... | |
double | skewness () |
return the skewness of the distribution More... | |
double | kurtosis () |
return the kurtosis of the distribution More... | |
std::vector< double > | moments () |
return the moments of the distribution distribution More... | |
double | median () |
return the median of the distibution More... | |
double | percentile (const unsigned int i) |
return the i-th percentile of the distribution More... | |
double | mode () |
return the distribution mode More... | |
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 More... | |
Constructors/destructors | |
Distribution () | |
default constructor | |
Distribution (const DistributionType distributionType, const double value) | |
constructor of a constant distribution More... | |
Distribution (const DistributionType distributionType, const double xmin, const double xmax, const int seed=3213) | |
constructor of a flat distribution More... | |
Distribution (const DistributionType distributionType, const std::vector< double > distribution_params, const double xmin, const double xmax, const int seed=1) | |
constructor More... | |
Distribution (const DistributionType distributionType, const distribution_func func, const std::shared_ptr< void > distribution_fixed_pars, const std::vector< double > distribution_pars, const double xmin, const double xmax, const int seed=1) | |
constructor More... | |
Distribution (const DistributionType distributionType, const std::vector< double > discrete_values, const std::vector< double > weights, const int seed=1) | |
constructor More... | |
Distribution (const DistributionType distributionType, const std::vector< double > var, const std::vector< double > dist, const int nbin, const std::string interpolationType, const int seed=1) | |
constructor More... | |
~Distribution ()=default | |
default destructor | |
Protected Member Functions | |
void | m_set_distribution_normalization () |
set distribution normalization | |
double | m_moments_integrator (const double xx, const unsigned int order) |
integrand of the moments distribution More... | |
double | m_central_moments_integrator (const double xx, const unsigned int order) |
integrand of the central moments of the distribution More... | |
double | m_percentile_integrator (const double xx) |
integrand of the percentile of the distribution More... | |
Protected Attributes | |
DistributionType | m_distributionType |
the type of distribution | |
distribution_func | m_func |
the probability distribution function | |
std::shared_ptr< random::RandomNumbers > | m_distribution_random |
the distribution random generator | |
double | m_xmin |
the distribution lower limit | |
double | m_xmax |
the distribution upper limit | |
std::vector< double > | m_distribution_func_pars |
the parameters of the distribution function | |
std::shared_ptr< void > | m_distribution_func_fixed_pars |
void pointer for the distribution function | |
double | m_distribution_normalization |
the distribution normalization | |
double | m_log_distribution_normalization |
the natural log of distribution normalization | |
double | m_mean |
the distribution mean | |
double | m_variance |
the distribution variance | |
double | m_sigma |
the distribution standard deviation | |
int | m_seed |
the distribution seed | |
The class CombinedDistribution.
The class Distribution.
This class is used to define the N-dimensional distribution
This class is used to define the distribution
Definition at line 124 of file Distribution.h.
cbl::glob::Distribution::Distribution | ( | const DistributionType | distributionType, |
const double | value | ||
) |
constructor of a constant distribution
distributionType | the type of distribution to be created |
value | the value to be returned |
Definition at line 67 of file Distribution.cpp.
cbl::glob::Distribution::Distribution | ( | const DistributionType | distributionType, |
const double | xmin, | ||
const double | xmax, | ||
const int | seed = 3213 |
||
) |
constructor of a flat distribution
distributionType | the type of distribution to be created |
xmin | lower limit of the distribution |
xmax | upper limit of the distribution |
seed | the distribution seed for random sampling |
Definition at line 80 of file Distribution.cpp.
cbl::glob::Distribution::Distribution | ( | const DistributionType | distributionType, |
const std::vector< double > | distribution_params, | ||
const double | xmin, | ||
const double | xmax, | ||
const int | seed = 1 |
||
) |
constructor
distributionType | the type of distribution to be created |
distribution_params | parameters of the distribution function or discrete list of values for discrete distribution |
xmin | lower limit of the distribution |
xmax | upper limit of the distribution |
seed | the distribution seed for random sampling |
Definition at line 92 of file Distribution.cpp.
cbl::glob::Distribution::Distribution | ( | const DistributionType | distributionType, |
const distribution_func | func, | ||
const std::shared_ptr< void > | distribution_fixed_pars, | ||
const std::vector< double > | distribution_pars, | ||
const double | xmin, | ||
const double | xmax, | ||
const int | seed = 1 |
||
) |
constructor
distributionType | the type of distribution to be created |
func | the functional form of the distribution |
distribution_fixed_pars | the fixed parameters |
distribution_pars | the distribution parameters |
xmin | lower limit of the distribution |
xmax | upper limit of the distribution |
seed | the distribution seed for random sampling |
Definition at line 118 of file Distribution.cpp.
cbl::glob::Distribution::Distribution | ( | const DistributionType | distributionType, |
const std::vector< double > | discrete_values, | ||
const std::vector< double > | weights, | ||
const int | seed = 1 |
||
) |
constructor
distributionType | the type of distribution to be created |
discrete_values | list of discrete values |
weights | list of weights for discrete values |
seed | the distribution seed for random sampling |
Definition at line 132 of file Distribution.cpp.
cbl::glob::Distribution::Distribution | ( | const DistributionType | distributionType, |
const std::vector< double > | var, | ||
const std::vector< double > | dist, | ||
const int | nbin, | ||
const std::string | interpolationType, | ||
const int | seed = 1 |
||
) |
constructor
distributionType | the type of distribution to be created |
var | vector containing binned values |
dist | list of distribution values for each bin |
nbin | the number of bins |
interpolationType | the kind of interpolation |
seed | the distribution seed for random sampling |
Definition at line 144 of file Distribution.cpp.
|
inline |
the distribution range
Definition at line 470 of file Distribution.h.
|
inline |
return the distribution type
Definition at line 316 of file Distribution.h.
void cbl::glob::Distribution::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
[out] | xx | std::vector containing the binned values of the variable |
[out] | fx | std::vector containing the binned values of the distribution |
[out] | err | std::vector containing the binned Poisson errors |
[in] | FF | std::vector containing the given set of data |
[in] | WW | std::vector containing the weights |
[in] | nbin | the number of bins |
[in] | linear | true → linear binning; false → logarithmic binning |
[in] | file_out | the output file where the distribution is stored |
[in] | fact | factor used to normalized the distribution |
[in] | V1 | the minimum limit of the distribution |
[in] | V2 | the maximum limit of the distribution |
[in] | bin_type | true → dn/dvar; false → dn/dlogvar |
[in] | conv | true → compute the Gaussian convolvolution of the distribution; false → do not convolve |
[in] | sigma | σ of the Gaussian kernel |
Definition at line 580 of file Distribution.cpp.
|
inline |
return the private member m_mean
Definition at line 448 of file Distribution.h.
|
inline |
return the private member m_seed
Definition at line 462 of file Distribution.h.
|
inline |
return the private member m_sigma
Definition at line 455 of file Distribution.h.
bool cbl::glob::Distribution::isIncluded | ( | const double | value | ) | const |
check if a value is included in the distribution limits
value | the value to be checked |
Definition at line 359 of file Distribution.cpp.
double cbl::glob::Distribution::kurtosis | ( | ) |
return the kurtosis of the distribution
Definition at line 485 of file Distribution.cpp.
double cbl::glob::Distribution::log_distribution | ( | double | xx | ) |
evaluate log-distribution
xx | the value for distribution calculation |
Definition at line 175 of file Distribution.cpp.
|
inlineprotected |
integrand of the central moments of the distribution
xx | the integration variable |
order | moment order |
Definition at line 192 of file Distribution.h.
|
inlineprotected |
integrand of the moments distribution
xx | the integration variable |
order | moment order |
Definition at line 180 of file Distribution.h.
|
protected |
integrand of the percentile of the distribution
xx | the integration variable |
Definition at line 45 of file Distribution.cpp.
double cbl::glob::Distribution::mean | ( | ) |
return the mean value of the distribution
Definition at line 408 of file Distribution.cpp.
|
inline |
return the median of the distibution
Definition at line 558 of file Distribution.h.
double cbl::glob::Distribution::mode | ( | ) |
return the distribution mode
Definition at line 541 of file Distribution.cpp.
vector< double > cbl::glob::Distribution::moments | ( | ) |
return the moments of the distribution distribution
Definition at line 507 of file Distribution.cpp.
double cbl::glob::Distribution::operator() | ( | double | xx | ) |
evaluate distribution
xx | the value for distribution calculation |
Definition at line 165 of file Distribution.cpp.
double cbl::glob::Distribution::percentile | ( | const unsigned int | i | ) |
return the i-th percentile of the distribution
i | the percentile |
Definition at line 516 of file Distribution.cpp.
double cbl::glob::Distribution::sample | ( | ) | const |
sample a value from the distribution
Definition at line 371 of file Distribution.cpp.
double cbl::glob::Distribution::sample | ( | const int | seed | ) |
sample a value from the distribution
seed | the seed for random number generation |
Definition at line 383 of file Distribution.cpp.
vector< double > cbl::glob::Distribution::sample_vector | ( | const int | nvalues | ) |
sample values from the distribution
nvalues | the number of points to be generated |
Definition at line 393 of file Distribution.cpp.
void cbl::glob::Distribution::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
var | vector containing binned values |
dist | list of distribution values for each bin |
interpolationType | the kind of interpolation |
seed | the distribution seed for random sampling |
Definition at line 336 of file Distribution.cpp.
void cbl::glob::Distribution::set_constant_distribution | ( | const double | value | ) |
set a constant distribution
value | the value to be returned |
Definition at line 195 of file Distribution.cpp.
void cbl::glob::Distribution::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
func | the functional form of the distribution |
distribution_fixed_pars | the fixed parameters |
distribution_pars | the distribution parameters |
seed | the distribution seed for random sampling |
Definition at line 317 of file Distribution.cpp.
void cbl::glob::Distribution::set_discrete_values | ( | const std::vector< double > | discrete_values, |
const std::vector< double > | weights, | ||
const int | seed = 1 |
||
) |
set discrete distribution values and weights
discrete_values | vector containing discrete values |
weights | list of weights for discrete values |
seed | the distribution seed for random sampling |
Definition at line 286 of file Distribution.cpp.
void cbl::glob::Distribution::set_gaussian_distribution | ( | const double | mean, |
const double | sigma, | ||
const int | seed = 1 |
||
) |
set normal distribution
mean | the normal distribution mean |
sigma | the normal distribution standard deviation |
seed | the distribution seed for random sampling |
Definition at line 233 of file Distribution.cpp.
void cbl::glob::Distribution::set_limits | ( | const double | xmin, |
const double | xmax | ||
) |
set the distribution limits
xmin | lower limit of the distribution |
xmax | upper limit of the distribution |
Definition at line 185 of file Distribution.cpp.
void cbl::glob::Distribution::set_poisson_distribution | ( | const double | mean, |
const int | seed = 1 |
||
) |
set poisson distribution
mean | the poisson distribution mean |
seed | the distribution seed for random sampling |
Definition at line 255 of file Distribution.cpp.
|
inline |
set distribution seed
seed | the distribution seed |
Definition at line 343 of file Distribution.h.
void cbl::glob::Distribution::set_uniform_distribution | ( | const double | xmin, |
const double | xmax, | ||
const int | seed = 1 |
||
) |
set an uniform distribution with input limits and seed
xmin | lower limit of the distribution |
xmax | upper limit of the distribution |
seed | the distribution seed for random sampling |
Definition at line 211 of file Distribution.cpp.
double cbl::glob::Distribution::skewness | ( | ) |
return the skewness of the distribution
Definition at line 463 of file Distribution.cpp.
double cbl::glob::Distribution::std | ( | ) |
return the standard deviation of the distribution
Definition at line 454 of file Distribution.cpp.
double cbl::glob::Distribution::variance | ( | ) |
return the standard deviation of the distribution
Definition at line 430 of file Distribution.cpp.
|
inline |
return the private member m_xmax
Definition at line 441 of file Distribution.h.
|
inline |
return the private member m_xmin
Definition at line 434 of file Distribution.h.