Calculates the error function of a floating-point number
#include <math.h>
double erf ( double x );
float erff ( float x );
long double erfl ( long double x );
The function erf( ), called the error function, is associated with the Gaussian function or normal distribution. If the measured values of a given random variable conform to a normal distribution with the standard deviation s, then the probability that a single measurement has an error within ± a is erf( a / (s x 2) ). The return value of erf(x) is The function erfc( ) is the complementary error function, defined as erfc(x) = 1 - erf(x).
Example
/*
* Given a normal distribution with mean 0 and standard deviation 1,
* calculate the probability that the random variable is within the
* range [0, 1.125]
*/
double sigma = 1.0; // The standard deviation
double bound = 1.125;
double probability; // probability that mean <= value <= bound
probability = 0.5 * erf( bound / (sigma * sqrt(2.0)) );
See Also
erfc( )
|