Example usage for org.apache.commons.math3.distribution PoissonDistribution cumulativeProbability

List of usage examples for org.apache.commons.math3.distribution PoissonDistribution cumulativeProbability

Introduction

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

Prototype

public double cumulativeProbability(int x) 

Source Link

Usage

From source file:net.openhft.smoothie.MathDecisions.java

private static double footprint(int averageEntries, int refSize, int upFrontScale, int cap) {
    PoissonDistribution p = new PoissonDistribution(averageEntries);
    double stayCapProb = p.cumulativeProbability(cap);
    int objectHeaderSize = 8 + refSize;
    int segmentSize = objectSizeRoundUp((objectHeaderSize + (Segment.HASH_TABLE_SIZE * 2) + 8 + /* bit set */
            4 /* tier */ + (cap * 2 * refSize)));
    double totalSegmentsSize = (stayCapProb + (1 - stayCapProb) * 2) * segmentSize;
    int segmentsArraySize = refSize << upFrontScale;

    return (totalSegmentsSize + segmentsArraySize) / averageEntries;
}

From source file:net.openhft.smoothie.MathDecisions.java

/**
 * Computes number of segments, from which probability of doubling (quadrupling, eight-ing)
 * segments array according to Poisson distribution laws exceeds {@link #THRESHOLD} assuming
 * perfectly uniform hash code distribution, for each rounded up average number of entries per
 * segment. In this case we are going to allocate doubled (quadrupled, eight-ed) segments array
 * up front, to avoid even little pause and garbaging previous segments array.
 *///from  www.j a  v  a2 s . co m
private static void printSegmentsToScaleSegmentsArrayFrom(int min, int max, int refSize) {
    System.out.println("Segments to double (quadruple, eight) segments from:");
    for (int d = 1; d <= 4; d *= 2) {
        for (int i = min; i <= max; i++) {
            PoissonDistribution p = new PoissonDistribution(i / (1.0 * d));
            int cap = cap(i, refSize);
            System.out.printf("%d, ", (long) (THRESHOLD / (1.0 - p.cumulativeProbability(cap))));
        }
        System.out.println();
    }
}

From source file:org.deidentifier.arx.criteria.KMap.java

/**
 * Calculates k, based on Poisson distribution.
 * @param lambda/*from  w w w. jav a2s.com*/
 * @return
 */
private int calculateKPoisson(double lambda) {

    final double threshold = 1d - this.significanceLevel;
    final PoissonDistribution distribution = new PoissonDistribution(lambda);
    int counter = 0;
    double value = 0;
    while (value < threshold) {
        // value += (Math.pow(lambda, counter) * Math.exp(-lambda)) / ArithmeticUtils.factorial(counter);
        value = distribution.cumulativeProbability(counter);
        counter++;
        // Break if the estimated k is equal or greater than the given k, as this makes no sense.
        if (counter >= this.k) {
            // We are 100% sure that the dataset fulfills k-map
            value = 1d;
            break;
        }
    }
    this.type1Error = 1d - value;
    return counter + 1;
}

From source file:org.gitools.analysis.stats.test.BinomialTest.java

private static CommonResult resultWithPoisson(int observed, int n, double p, double expectedMean,
        double expectedStdev) {

    double leftPvalue;
    double rightPvalue;
    double twoTailPvalue;

    try {/*from w  w w .ja va 2 s .c o m*/
        PoissonDistribution poisson = new PoissonDistribution(expectedMean);

        leftPvalue = poisson.cumulativeProbability(observed);
        rightPvalue = observed > 0 ? poisson.cumulativeProbability(observed - 1, n) : 1.0;

        twoTailPvalue = (observed <= expectedMean ? leftPvalue : rightPvalue) * 2; //FIXME: Review
        twoTailPvalue = twoTailPvalue > 1.0 ? 1.0 : twoTailPvalue;
    } catch (ArithmeticException e) {
        leftPvalue = rightPvalue = twoTailPvalue = Double.NaN;
    }

    return new BinomialResult(BinomialResult.Distribution.POISSON, n, leftPvalue, rightPvalue, twoTailPvalue,
            observed, expectedMean, expectedStdev, p);
}