Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Commons Math Normal Cumulative Probability

Wikipedia has listed a variety of numerical methods for computing cumulative probability of a normal distribution. However, with Apache Commons Math you do not need know about any of them as the library simply does the job for you:

NormalDistribution normal = new NormalDistribution(mu, sigma);
normal.cumulativeProbability(x);

For some research project, I'm interested to know what method they use. Does anyone know what method Apache Commons Math uses to approximate the normal cumulative value? Is it from the methods listed in wikipedia or they have implemented something different?

like image 385
Pro.Hessam Avatar asked Jul 09 '26 07:07

Pro.Hessam


2 Answers

The beauty of open source software is that you can always check the source code. The implementation of cumulativeProbability is rather simple, it just returns

0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2)));

where Erf.erf computes the error function. It's defined here.

And no, it doesn' use any of the special methods in the mentioned Wikipedia article. It's just a straight-forward implementation of the formula

enter image description here

like image 173
Carsten Avatar answered Jul 11 '26 00:07

Carsten


You can probably see the source code or the javadoc. See there http://commons.apache.org/proper/commons-math/source-repository.html

and

http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/distribution/NormalDistribution.html

Also, there is alot of information in the user's guide. The section about distribution seems interesting: http://commons.apache.org/proper/commons-math/userguide/distribution.html

like image 31
JFPicard Avatar answered Jul 11 '26 00:07

JFPicard