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

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

Introduction

In this page you can find the example usage for org.apache.commons.math.distribution ZipfDistribution 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.AlgoZipf.java

protected final void compute() {

    if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) {
        int param = (int) a.getDouble();
        double param2 = b.getDouble();
        double val = c.getDouble();
        try {// w ww.ja v  a 2s . com
            ZipfDistribution dist = getZipfDistribution(param, param2);
            if (isCumulative.getBoolean())
                num.setValue(dist.cumulativeProbability(val)); // P(X <= val)
            else
                num.setValue(dist.probability(val)); // P(X = val)

        } catch (Exception e) {
            num.setUndefined();
        }
    } else
        num.setUndefined();
}

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

@Override
public final void compute() {

    if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) {
        int param = (int) a.getDouble();
        double param2 = b.getDouble();
        double val = c.getDouble();
        try {//from  w w  w  .j  a  v  a2s  .  c o  m
            ZipfDistribution dist = getZipfDistribution(param, param2);
            if (isCumulative.getBoolean())
                num.setValue(dist.cumulativeProbability(val)); // P(X <=
            // val)
            else
                num.setValue(dist.probability(val)); // P(X = val)

        } catch (Exception e) {
            num.setUndefined();
        }
    } else
        num.setUndefined();
}