A Generic Tabulated distribution. More...
#include <XeStat.h>
Public Member Functions | |
void | addDelta (double x, double w=1.) |
add one delta in the distribution, normalize and cumulate | |
double | cdf (double x) |
returns cumulated probability density function | |
void | drawCumulatedGraph (string options="C", string Xlab="", string Ylab="", XeStyle *style=NULL) |
Draw the cumulated distribution as a graph. | |
void | drawCumulatedGraphWithFrame (string options="C", string Xlab="", string Ylab="", XeStyle *style=NULL) |
Draw the cumulatedDistribution as a graph with its frame. | |
void | drawCumulatedHist (string options="C", string Xlab="", string Ylab="") |
Draw the cumulatedDistribution as an histogram. | |
virtual void | fillValues (double *values, int nValues) |
Build the distribution from an list of realizations. | |
double | generate () |
generate a variable according to the distribution | |
map< double, int > * | getCdfMap () |
vector< double > * | getCdfVector () |
double * | getCumulated () |
Return cumulated values. | |
void | importDistribution (XeDist *dist) |
Set the spectrum of the distribution from a distribution, normalize and cumulate. | |
void | importSpectrum (XeSpectrum *spectrum) |
Copy content of distribution from a spectrum, normalize and cumulate. | |
void | importSpectrum (vector< double > &spectrum) |
Copy content of distribution from a vector, normalize and cumulate. | |
void | importSpectrum (double *array) |
Copy content of distribution from an array, normalize and cumulate. | |
XeGraph * | newCumulatedGraph (string Xlab="", string Ylab="", XeStyle *style=NULL, string legend="") |
TH1F * | newCumulatedHistogram (string name="", int plot=NONE) |
void | normalizeAndCumulate () |
Normalized to 1 then Cumulate the tabulated distribution. | |
double | pdf (double x) |
returns probability density function | |
bool | printCumulated (int level=1) |
print the cumulated distribution | |
bool | printIt (int level=1) |
print the distribution | |
int | quantileBin (double c) |
Convert cdf into a bin number (to find the top 10%, etc. | |
double | quantileX (double c) |
Convert cdf into x (to find the top 10%, etc. | |
TabulatedDist (string nam, int nBins, double min, double max, XeValues *values) | |
Constructor from an XeValue of realizations. | |
TabulatedDist (string nam, int nbins, double min, double max, double *spec=NULL, int nValues=0, int mode=SPECTRUM) | |
Constructor from an array of either the spectrum of realizations. | |
TabulatedDist (XeSpectrum *sp) | |
Constructor from an XeSpectrum. | |
TabulatedDist (string nam, LinearRange *lr, double *spec=NULL, int nValues=0, int mode=SPECTRUM) | |
Constructor giving Linear Range. | |
TabulatedDist (string n) | |
Constructor with name only. | |
TabulatedDist () | |
Empty Constructor for ROOT. | |
Protected Attributes | |
map< double, int > | cdfMap |
vector< double > | cdfVector |
A Generic Tabulated distribution.
This is a virtual class. It is a untity normalized XeSpectrum
TabulatedDist::TabulatedDist | ( | string | nam, | |
LinearRange * | lr, | |||
double * | spec = NULL , |
|||
int | nValues = 0 , |
|||
int | mode = SPECTRUM | |||
) |
Constructor giving Linear Range.
nam | name of the original quantity | |
lr | LinearRange describing the bins |
TabulatedDist::TabulatedDist | ( | string | nam, | |
int | nbins, | |||
double | min, | |||
double | max, | |||
double * | spec = NULL , |
|||
int | nValues = 0 , |
|||
int | mode = SPECTRUM | |||
) |
Constructor from an array of either the spectrum of realizations.
nam | name of the original quantity | |
nBins | Number of bins | |
min | lowest value of lowest bin | |
max | upper value of upper bin | |
spec | pointer to the spectrum to be copied (mode SPECTRUM) , or the values to be histogrammed (mode VALUES) if NULL, nothing is done | |
nValues | number of values | |
mode | whether spec refer to SPECTRUM or VALUES |
TabulatedDist::TabulatedDist | ( | string | nam, | |
int | nBins, | |||
double | min, | |||
double | max, | |||
XeValues * | values | |||
) |
Constructor from an XeValue of realizations.
nam | name of the original quantity | |
nBins | Number of bins | |
min | lowest value of lowest bin | |
max | upper value of upper bin | |
values | Original vector of values |
void TabulatedDist::addDelta | ( | double | x, | |
double | w = 1. | |||
) |
add one delta in the distribution, normalize and cumulate
x | where | |
w | weight |
double TabulatedDist::cdf | ( | double | x | ) | [virtual] |
returns cumulated probability density function
x | Point at which is it evaluated |
Implements XeDist.
void TabulatedDist::drawCumulatedGraph | ( | string | options = "C" , |
|
string | Xlab = "" , |
|||
string | Ylab = "" , |
|||
XeStyle * | style = NULL | |||
) |
Draw the cumulated distribution as a graph.
Xlab | label of x-axis | |
Ylb | label of y-axis | |
style | Style of the graph | |
options | TGraph->Draw() option |
void TabulatedDist::drawCumulatedGraphWithFrame | ( | string | options = "C" , |
|
string | Xlab = "" , |
|||
string | Ylab = "" , |
|||
XeStyle * | style = NULL | |||
) |
Draw the cumulatedDistribution as a graph with its frame.
Xlab | label of x-axis | |
Ylb | label of y-axis | |
style | Style of the graph | |
options | TGraph->Draw() option |
void TabulatedDist::drawCumulatedHist | ( | string | options = "C" , |
|
string | Xlab = "" , |
|||
string | Ylab = "" | |||
) |
Draw the cumulatedDistribution as an histogram.
options | THist->Draw() option |
virtual void TabulatedDist::fillValues | ( | double * | values, | |
int | nValues | |||
) | [virtual] |
Build the distribution from an list of realizations.
values | array of values | |
nValues | number of points |
Reimplemented from XeSpectrum.
double* TabulatedDist::getCumulated | ( | ) |
Return cumulated values.
void TabulatedDist::importDistribution | ( | XeDist * | dist | ) |
Set the spectrum of the distribution from a distribution, normalize and cumulate.
Note: the original distribution need not be tabulated
dist | mother distribution |
void TabulatedDist::importSpectrum | ( | XeSpectrum * | spectrum | ) |
Copy content of distribution from a spectrum, normalize and cumulate.
spectrum | vector of values to be copied |
void TabulatedDist::importSpectrum | ( | vector< double > & | spectrum | ) | [virtual] |
Copy content of distribution from a vector, normalize and cumulate.
spectrum | vector of values to be copied |
Reimplemented from XeSpectrum.
void TabulatedDist::importSpectrum | ( | double * | array | ) | [virtual] |
Copy content of distribution from an array, normalize and cumulate.
array | pointer to array of values to be copied |
Reimplemented from XeSpectrum.
XeGraph* TabulatedDist::newCumulatedGraph | ( | string | Xlab = "" , |
|
string | Ylab = "" , |
|||
XeStyle * | style = NULL , |
|||
string | legend = "" | |||
) |
Xlab | label of x-axis | |
Ylb | label of y-axis | |
style | Style of the graph | |
legend | Legend in case of a multi-graph |
TH1F* TabulatedDist::newCumulatedHistogram | ( | string | name = "" , |
|
int | plot = NONE | |||
) |
name | Name of the histogram | |
plot | either NONE, AUTO, LINEAR, or LOG |
double TabulatedDist::pdf | ( | double | x | ) | [virtual] |
returns probability density function
x | Point at which is it evaluated |
Implements XeDist.
bool TabulatedDist::printCumulated | ( | int | level = 1 |
) |
print the cumulated distribution
level | of print |
bool TabulatedDist::printIt | ( | int | level = 1 |
) | [virtual] |
print the distribution
level | print level (if >=3, also print cumulated distribution) |
Reimplemented from XeSpectrum.
int TabulatedDist::quantileBin | ( | double | c | ) |
Convert cdf into a bin number (to find the top 10%, etc.
..)
c | cdf value (i.e .5=median, .9=top 10%, etc...) |
double TabulatedDist::quantileX | ( | double | c | ) |
Convert cdf into x (to find the top 10%, etc.
..)
c | cdf value (i.e .5=median, .9=top 10%, etc...) |
map<double,int> TabulatedDist::cdfMap [protected] |
Used for generating according to this dist.
vector<double> TabulatedDist::cdfVector [protected] |
List of cumulated probabilities