December 2005
Beginner to intermediate
618 pages
20h 19m
English
erf
Calculates the error function of a floating-point number
#include <math.h> doubleerf( doublex); floaterff( floatx); long doubleerfl( long doublex);
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 σ, then the
probability that a single measurement has an error within ±
a is erf( a /
(σ × √2) ).
The return value of erf(x) is

The function erfc() is the
complementary error function, defined as erfc(x) = 1 − erf(x).
/*
* 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)) );Read now
Unlock full access