Example usage for org.apache.commons.math.distribution PoissonDistribution probability

List of usage examples for org.apache.commons.math.distribution PoissonDistribution probability

Introduction

In this page you can find the example usage for org.apache.commons.math.distribution PoissonDistribution probability.

Prototype

double probability(int x);

Source Link

Document

For a random variable X whose values are distributed according to this distribution, this method returns P(X = x).

Usage

From source file:geogebra.kernel.statistics.AlgoPoisson.java

@SuppressWarnings("deprecation")
protected final void compute() {

    if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) {
        double param = a.getDouble();
        double val = b.getDouble();
        try {//from  w w  w.j  a v  a2s . c  om
            PoissonDistribution dist = getPoissonDistribution(param);
            if (isCumulative.getBoolean())
                num.setValue(dist.cumulativeProbability(val)); // P(X <= val)
            else
                num.setValue(dist.probability(val)); // P(X = val)
        } catch (Exception e) {
            Application.debug(e.getMessage());
            num.setUndefined();
        }
    } else
        num.setUndefined();
}

From source file:geogebra.common.kernel.statistics.AlgoPoisson.java

@Override
@SuppressWarnings("deprecation")
public final void compute() {

    if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) {
        double param = a.getDouble();
        double val = b.getDouble();
        try {/* www .  j a v a 2  s. co m*/
            PoissonDistribution dist = getPoissonDistribution(param);
            if (isCumulative.getBoolean())
                num.setValue(dist.cumulativeProbability(val)); // P(X <=
            // val)
            else
                num.setValue(dist.probability(val)); // P(X = val)
        } catch (Exception e) {
            App.debug(e.getMessage());
            num.setUndefined();
        }
    } else
        num.setUndefined();
}

From source file:org.apache.mahout.knn.generate.PoissonSamplerTest.java

private void checkDistribution(PoissonSampler pd, double alpha) {
    int[] count = new int[(int) Math.max(10, 5 * alpha)];
    for (int i = 0; i < 10000; i++) {
        count[pd.sample().intValue()]++;
    }/*from  ww  w  .j av  a 2 s  .  c o m*/

    PoissonDistribution ref = new PoissonDistributionImpl(alpha);
    for (int i = 0; i < count.length; i++) {
        assertEquals(ref.probability(i), count[i] / 10000.0, 2e-2);
    }
}

From source file:org.geogebra.common.kernel.statistics.AlgoPoisson.java

@Override
public final void compute() {

    if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) {
        double param = a.getDouble();
        double val = b.getDouble();
        try {/*from   w  w  w . jav  a2 s  .c  om*/
            PoissonDistribution dist = getPoissonDistribution(param);
            if (isCumulative.getBoolean())
                num.setValue(dist.cumulativeProbability(val)); // P(X <=
            // val)
            else
                num.setValue(dist.probability(val)); // P(X = val)
        } catch (Exception e) {
            App.debug(e.getMessage());
            num.setUndefined();
        }
    } else
        num.setUndefined();
}