Calculate Normal Formula Using Java

EDIT:

In fact, I realized that I need the value of X. Let me make this clearer. Suppose I know the probability P = 0.95, since I want to use two standard deviations. I know the ranges of P (-500 <x <500) , which means that I know y and z, I know the mean and standard deviation. If I want to know what the value of x will be, which method should I use. I found one calculator , something like this, but couldn't figure out which formula to use.

The original question:

I want to calculate the normal probability of distributing random variables using Java. Not sure which formula to use for coding to solve a problem like this . If I know the mean and standard deviation and want to find the probability of being an x ​​value between two specific y and z values ​​(P (-500

Can anybody help me?

+3
source share
3 answers

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

: , @Brent Worden answer, . , examples, . , cumulativeProbability(), Erf.erf. , inverseCumulativeProbability() .

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 https://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));
    }
}

:

0.9772498680518208
62.81551565546365

:

1. , , 1000 100 , ~ 97,7% 1200 .

2. , , 50 10 , 90% 63 .

+10

commons-math NormalDistributionImpl:

    new org.apache.commons.math.distribution.NormalDistributionImpl(mean, std)
        .cumulativeProbability(a, b)

S P (a & le; X & le; b) X ~ N ( , std).

, , . , inverseCumulativeProbability. x p , P (X, le; x) = p.

+8

Colt, CERN, ; Normal (aka Gaussian) cern.jet.random.Normal.

+4

All Articles