LALPulsar  6.1.0.1-89842e6
ProbabilityDensity.c File Reference

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...
 

Detailed Description

Module implementing a probability density function (pdf) object, and useful methods to operate on such objects.

Author
R. Prix

Definition in file ProbabilityDensity.c.

Go to the source code of this file.

Macros

#define PDF_FMT   "%.16g"
 

Macro Definition Documentation

◆ PDF_FMT

#define PDF_FMT   "%.16g"

Function Documentation

◆ XLALDrawFromPDF1D()

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.

Parameters
[in]pdfprobability density to sample from
rngrandom-number generator

Definition at line 59 of file ProbabilityDensity.c.

◆ XLALCheckValidPDF1D()

int XLALCheckValidPDF1D ( const pdf1D_t *  pdf)

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.

◆ XLALDestroyPDF1D()

void XLALDestroyPDF1D ( pdf1D_t *  pdf)

Destructor function for 1-D pdf.

Definition at line 195 of file ProbabilityDensity.c.

◆ XLALCreateSingularPDF1D()

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

Parameters
x0domain of pdf is a single point: x0

Definition at line 226 of file ProbabilityDensity.c.

◆ XLALCreateUniformPDF1D()

pdf1D_t* XLALCreateUniformPDF1D ( REAL8  xMin,
REAL8  xMax 
)

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}

Parameters
xMinlower boundary of domain interval
xMaxupper boundary of domain interval

Definition at line 256 of file ProbabilityDensity.c.

◆ XLALCreateDiscretePDF1D()

pdf1D_t* XLALCreateDiscretePDF1D ( REAL8  xMin,
REAL8  xMax,
UINT4  numBins 
)

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]]

Parameters
xMinlower boundary of domain interval
xMaxupper boundary of domain interval
numBinsnumber of bins to discretize PDF into

Definition at line 296 of file ProbabilityDensity.c.

◆ XLALNormalizePDF1D()

int XLALNormalizePDF1D ( pdf1D_t *  pdf)

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.

◆ XLALOutputPDF1D_to_fp()

int XLALOutputPDF1D_to_fp ( FILE *  fp,
const pdf1D_t *  pdf,
const char name 
)

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] }

Parameters
fpoutput file-pointer to write into [append]
pdfinput pdf [need not be normalized]
nameoctave variable-name to use in output (default = 'pdf' if NULL)

Definition at line 406 of file ProbabilityDensity.c.

◆ XLALFindModeOfPDF1D()

REAL8 XLALFindModeOfPDF1D ( const pdf1D_t *  pdf)

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.