You are on page 1of 2

http://stackoverflow.

com/questions/6353678/calculate-normal-distrubutionusing-java

You can use the error function, available in org.apache.commons.math.special.Erf,


as discussedhere and here.
Addendum: The methods proposed in @Brent Worden's answer considerably
simplify the solution of such problems. As a concrete example, the code below
shows how to solve the examples to which you refer. In addition, I found it helpful to
compare the definition here to the implementation
of cumulativeProbability() using Erf.erf. Note also how the implementation
ofinverseCumulativeProbability() generalizes the required iterative approach.
import org.apache.commons.math.MathException;
import org.apache.commons.math.distribution.NormalDistribution;
import org.apache.commons.math.distribution.NormalDistributionImpl;
/**
* @see http://stattrek.com/Tables/Normal.aspx#examples
* @see http://stackoverflow.com/questions/6353678
*/
public class CumulativeProbability {
private static NormalDistribution d;
public static void main(String[] args) throws MathException {
// Problem 1; = 1000; = 100
d = new NormalDistributionImpl(1000, 100);
System.out.println(d.cumulativeProbability(1200));
// Problem 2; = 50; = 10
d = new NormalDistributionImpl(50, 10);
System.out.println(d.inverseCumulativeProbability(0.9));
}
}

Console:
0.9772498680518208
62.81551565546365

http://www.mathworks.com/help/stats/norminv.html

http://stackoverflow.com/questions/8816729/javascript-equivalent-forinverse-normal-function-eg-excels-normsinv-or-nor

http://stackoverflow.com/questions/442758/which-java-library-computes-thecumulative-standard-normal-distribution-function

You might also like