Module implementing a probability density function (pdf) object, and useful methods to operate on such objects. More...
Prototypes | |
REAL8 | XLALDrawFromPDF1D (pdf1D_t *pdf, const gsl_rng *rng) |
Function to generate random samples drawn from the given pdf(x) NOTE: if the 'sampling' field is NULL, it will be set the first call to this function. More... | |
int | XLALCheckValidPDF1D (const pdf1D_t *pdf) |
Checks internal consistency of pdf1D object. More... | |
void | XLALDestroyPDF1D (pdf1D_t *pdf) |
Destructor function for 1-D pdf. More... | |
pdf1D_t * | XLALCreateSingularPDF1D (REAL8 x0) |
Creator function for a 'singular' 1D pdf, containing a single value with certainty, ie P(x0)=1, and P(x!=x0)=0. More... | |
pdf1D_t * | XLALCreateUniformPDF1D (REAL8 xMin, REAL8 xMax) |
Creator function for a uniform 1D pdf over [xMin, xMax]. More... | |
pdf1D_t * | XLALCreateDiscretePDF1D (REAL8 xMin, REAL8 xMax, UINT4 numBins) |
Creator function for a generic discrete 1D pdf over [xMin, xMax], discretized into numBins bins. More... | |
int | XLALNormalizePDF1D (pdf1D_t *pdf) |
Method to normalize the given pdf1D. More... | |
int | XLALOutputPDF1D_to_fp (FILE *fp, const pdf1D_t *pdf, const char *name) |
Function to write a pdf1D to given filepointer fp. More... | |
REAL8 | XLALFindModeOfPDF1D (const pdf1D_t *pdf) |
Find the 'mode' of the probabilty distribution, ie. More... | |
Module implementing a probability density function (pdf) object, and useful methods to operate on such objects.
Definition in file ProbabilityDensity.c.
Go to the source code of this file.
Macros | |
#define | PDF_FMT "%.16g" |
#define PDF_FMT "%.16g" |
Function to generate random samples drawn from the given pdf(x) NOTE: if the 'sampling' field is NULL, it will be set the first call to this function.
[in] | probability density to sample from | |
rng | random-number generator |
Definition at line 59 of file ProbabilityDensity.c.
Checks internal consistency of pdf1D object.
If lalDebugLevel > 0, also checks normalization of pdf if it claims to be normalized.
Return: XLAL_SUCCESS if pdf seems OK, XLAL-error otherwise
Definition at line 130 of file ProbabilityDensity.c.
void XLALDestroyPDF1D | ( | pdf1D_t * | ) |
Destructor function for 1-D pdf.
Definition at line 195 of file ProbabilityDensity.c.
pdf1D_t* XLALCreateSingularPDF1D | ( | REAL8 | x0 | ) |
Creator function for a 'singular' 1D pdf, containing a single value with certainty, ie P(x0)=1, and P(x!=x0)=0.
This is encoded as an xTics array containing just one value: x0, and prob=NULL, sampling=NULL
x0 | domain of pdf is a single point: x0 |
Definition at line 226 of file ProbabilityDensity.c.
Creator function for a uniform 1D pdf over [xMin, xMax].
This is encoded as an xTics array containing just two values: x[0]=xMin, x[1]=xMax, and prob=NULL, sampling=NULL {not required to draw from this pdf}
xMin | lower boundary of domain interval |
xMax | upper boundary of domain interval |
Definition at line 256 of file ProbabilityDensity.c.
Creator function for a generic discrete 1D pdf over [xMin, xMax], discretized into numBins bins.
NOTE: generates a uniform sampling of the domain [xMin, xMax] in numBins NOTE2: returns the P[i] array 'prob' initialized to 0, so after calling this function the user still needs to feed in the correct values for the probabilities P[i] of x in [x[i],x[i+1]]
xMin | lower boundary of domain interval |
xMax | upper boundary of domain interval |
numBins | number of bins to discretize PDF into |
Definition at line 296 of file ProbabilityDensity.c.
int XLALNormalizePDF1D | ( | pdf1D_t * | ) |
Method to normalize the given pdf1D.
Only does something if necessary, ie if pdf isn't normalized already
Definition at line 352 of file ProbabilityDensity.c.
Function to write a pdf1D to given filepointer fp.
Writes the pdf in octave format as a 2xN matrix, containing values { xtics[i], pdf[i] }
fp | output file-pointer to write into [append] |
input pdf [need not be normalized] | |
name | octave variable-name to use in output (default = 'pdf' if NULL) |
Definition at line 406 of file ProbabilityDensity.c.
Find the 'mode' of the probabilty distribution, ie.
the value x at which the pdf has its maximum.
Note1: We return the center-value of the discrete 'bin' containing the maximum of the distribution 'pdf'. (in particular, for an explicitly uniform distribution (2 tics, probDens=NULL) we return the mid-point of the domain).
Note2: If the mode is not unique, we return the first (ie 'leftmost') value of x.
Definition at line 495 of file ProbabilityDensity.c.