JWS C Library
C language utility library
pdf.c File Reference

Definitions for univariate probability density functions. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include "jwsc/base/limits.h"
#include "jwsc/math/constants.h"
#include "jwsc/math/slatec.h"
#include "jwsc/prob/pdf.h"
Include dependency graph for pdf.c:

Go to the source code of this file.

Defines

#define SQRT_2_PI_SINGLE   2.5066282746310004f
 Single precision sqrt of two pi.
#define SQRT_2_PI_DOUBLE   2.50662827463100050241576528481103
 Double precision sqrt of two pi.
#define INV_SQRT_2_PI_SINGLE   0.3989422804014326f
 Single precision inverse sqrt of two pi.
#define INV_SQRT_2_PI_DOUBLE   0.39894228040143267793994605993438
 Double precision inverse sqrt of two pi.
#define LOG_SQRT_2_PI_SINGLE   0.9189385332046727
 Single precision log sqrt of two pi.
#define LOG_SQRT_2_PI_DOUBLE   .91893853320467274178032973640561
 Double precision log sqrt of two pi.

Functions

standard_gaussian_pdf

Computes the univariate standard Gaussian pdf at a point.

float standard_gaussian_pdf_f (float x)
 Computes the single precision univariate standard Gaussian pdf at a point.
double standard_gaussian_pdf_d (double x)
 Computes the double precision univariate standard Gaussian pdf at a point.
gaussian_pdf

Computes the univariate Gaussian pdf at a point.

float gaussian_pdf_f (float mu, float sigma, float x)
 Computes the single precision univariate Gaussian pdf at a point.
double gaussian_pdf_d (double mu, double sigma, double x)
 Computes the double precision univariate Gaussian pdf at a point.
log_standard_gaussian_pdf

Computes the log of the univariate standard Gaussian pdf at a point.

float log_standard_gaussian_pdf_f (float x)
 Computes the single precision log of the univariate standard Gaussian pdf at a point.
double log_standard_gaussian_pdf_d (double x)
 Computes the double precision log of the univariate standard Gaussian pdf at a point.
log_gaussian_pdf

Computes the log of the univariate Gaussian pdf at a point.

float log_gaussian_pdf_f (float mu, float sigma, float x)
 Computes the single precision log of the univariate Gaussian pdf at a point.
double log_gaussian_pdf_d (double mu, double sigma, double x)
 Computes the double precision log of the univariate Gaussian pdf at a point.
sample_standard_gaussian_pdf

Draws a random sample from the standard Gaussian pdf.

float sample_standard_gaussian_pdf_f (float a, float b)
 Draws a single precision random sample from the standard Gaussian pdf.
double sample_standard_gaussian_pdf_d (double a, double b)
 Draws a double precision random sample from the standard Gaussian pdf.
sample_gaussian_pdf

Draws a random sample from the Gaussian pdf.

float sample_gaussian_pdf_f (float mu, float sigma, float a, float b)
 Draws a single precision random sample from the Gaussian pdf.
double sample_gaussian_pdf_d (double mu, double sigma, double a, double b)
 Draws a double precision random sample from the Gaussian pdf.
sample_uniform_pdf

Draws a random sample from the Uniform pdf.

float sample_uniform_pdf_f (float a, float b)
 Draws a single precision random sample from the Uniform pdf.
double sample_uniform_pdf_d (double a, double b)
 Draws a double precision random sample from the Uniform pdf.
sample_sine_pdf

Draws a random sample from the Sine pdf over the interval [0,PI/2].

float sample_sine_pdf_f ()
 Draws a single precision random sample from the Sine pdf over the interval [0,PI/2].
double sample_sine_pdf_d ()
 Draws a double precision random sample from the Sine pdf over the interval [0.PI/2].

Detailed Description

Definitions for univariate probability density functions.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file pdf.c.


Define Documentation

#define SQRT_2_PI_SINGLE   2.5066282746310004f

Single precision sqrt of two pi.

Definition at line 60 of file pdf.c.

#define SQRT_2_PI_DOUBLE   2.50662827463100050241576528481103

Double precision sqrt of two pi.

Definition at line 63 of file pdf.c.

#define INV_SQRT_2_PI_SINGLE   0.3989422804014326f

Single precision inverse sqrt of two pi.

Definition at line 66 of file pdf.c.

#define INV_SQRT_2_PI_DOUBLE   0.39894228040143267793994605993438

Double precision inverse sqrt of two pi.

Definition at line 69 of file pdf.c.

#define LOG_SQRT_2_PI_SINGLE   0.9189385332046727

Single precision log sqrt of two pi.

Definition at line 72 of file pdf.c.

#define LOG_SQRT_2_PI_DOUBLE   .91893853320467274178032973640561

Double precision log sqrt of two pi.

Definition at line 75 of file pdf.c.


Function Documentation

float standard_gaussian_pdf_f ( float  x)

Computes the single precision univariate standard Gaussian pdf at a point.

Uses mean zero and variance one.

Parameters:
xPoint to evaluate the pdf at.
Returns:
Density of the standard Gaussian at x.

Definition at line 92 of file pdf.c.

double standard_gaussian_pdf_d ( double  x)

Computes the double precision univariate standard Gaussian pdf at a point.

Parameters:
xPoint to evaluate the pdf at.
Returns:
Density of the standard Gaussian at x.

Definition at line 102 of file pdf.c.

float gaussian_pdf_f ( float  mu,
float  sigma,
float  x 
)

Computes the single precision univariate Gaussian pdf at a point.

Parameters:
muMean of the Gaussian.
sigmaStandard deviation of the Gaussian.
xPoint to evaluate the pdf at.
Returns:
Density of the Gaussian at x.

Definition at line 124 of file pdf.c.

double gaussian_pdf_d ( double  mu,
double  sigma,
double  x 
)

Computes the double precision univariate Gaussian pdf at a point.

Parameters:
muMean of the Gaussian.
sigmaStandard deviation of the Gaussian.
xPoint to evaluate the pdf at.
Returns:
Density of the Gaussian at x.

Definition at line 139 of file pdf.c.

float log_standard_gaussian_pdf_f ( float  x)

Computes the single precision log of the univariate standard Gaussian pdf at a point.

Parameters:
xValue to get the log likelihood of.
Returns:
Log density of the standard Gaussian at x.

Definition at line 162 of file pdf.c.

double log_standard_gaussian_pdf_d ( double  x)

Computes the double precision log of the univariate standard Gaussian pdf at a point.

Parameters:
xValue to get the log likelihood of.
Returns:
Log density of the standard Gaussian at x.

Definition at line 172 of file pdf.c.

float log_gaussian_pdf_f ( float  mu,
float  sigma,
float  x 
)

Computes the single precision log of the univariate Gaussian pdf at a point.

Parameters:
muMean of the Gaussian.
sigmaStandard deviation of the Gaussian.
xValue to get the log likelihood of.
Returns:
Log density of the Gaussian at x.

Definition at line 194 of file pdf.c.

double log_gaussian_pdf_d ( double  mu,
double  sigma,
double  x 
)

Computes the double precision log of the univariate Gaussian pdf at a point.

Parameters:
muMean of the Gaussian.
sigmaStandard deviation of the Gaussian.
xValue to get the log likelihood of.
Returns:
Log density of the Gaussian at x.

Definition at line 213 of file pdf.c.

float sample_standard_gaussian_pdf_f ( float  a,
float  b 
)

Draws a single precision random sample from the standard Gaussian pdf.

Parameters:
aLower bound of the sampling interval.
bUpper bound of the sampling interval.
Returns:
A random sample from the standard Gaussian density over the interval [a,b].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 327 of file pdf.c.

double sample_standard_gaussian_pdf_d ( double  a,
double  b 
)

Draws a double precision random sample from the standard Gaussian pdf.

Parameters:
aLower bound of the sampling interval.
bUpper bound of the sampling interval.
Returns:
A random sample from the standard Gaussian density over the interval [a,b].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 359 of file pdf.c.

float sample_gaussian_pdf_f ( float  mu,
float  sigma,
float  a,
float  b 
)

Draws a single precision random sample from the Gaussian pdf.

Parameters:
muMean of the Gaussian.
sigmaStandard deviation of the Gaussian
aLower bound of the sampling interval.
bUpper bound of the sampling interval.
Returns:
A random sample from the Gaussian density with mean mu and standard deviation sigma over the interval [a,b].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 404 of file pdf.c.

double sample_gaussian_pdf_d ( double  mu,
double  sigma,
double  a,
double  b 
)

Draws a double precision random sample from the Gaussian pdf.

Parameters:
muMean of the Gaussian.
sigmaStandard deviation of the Gaussian
aLower bound of the sampling interval.
bUpper bound of the sampling interval.
Returns:
A random sample from the Gaussian density with mean mu and standard deviation sigma over the interval [a,b].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 447 of file pdf.c.

float sample_uniform_pdf_f ( float  a,
float  b 
)

Draws a single precision random sample from the Uniform pdf.

Parameters:
aLower bound of the sampling interval.
bUpper bound of the sampling interval.
Returns:
A random sample from the specified uniform density over the interval [a,b].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 706 of file pdf.c.

double sample_uniform_pdf_d ( double  a,
double  b 
)

Draws a double precision random sample from the Uniform pdf.

Parameters:
aLower bound of the sampling interval.
bUpper bound of the sampling interval.
Returns:
A random sample from the specified uniform density over the interval [a,b].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 726 of file pdf.c.

float sample_sine_pdf_f ( )

Draws a single precision random sample from the Sine pdf over the interval [0,PI/2].

Returns:
A random sample from the sine density function over the interval [0, PI/2].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 753 of file pdf.c.

double sample_sine_pdf_d ( )

Draws a double precision random sample from the Sine pdf over the interval [0.PI/2].

Returns:
A random sample from the sine density function over the interval [0, PI/2].
Note:
Does not seed the rand() function. If this is desired, srand() must be called prior to calling this function.

Definition at line 782 of file pdf.c.