fbpx

C++: Normal PDF

Bjarne-stroustrup
 

const double Pi = 3.14159265359;

// Standard Normal probability density function
double Normal_PDF(const double & x)
// Normal PDF(x) = exp(-x*x/2)/{sigma * sqrt(2 * Pi) }
{ return (1.0/(double)pow(2 * Pi, 0.5)) * exp(-0.5 * x * x); }