/** * Create a new Poisson distribution with the given the mean. The mean value * must be positive; otherwise an <code>IllegalArgument</code> is thrown. * * @param p the Poisson mean * @throws IllegalArgumentException if p ≤ 0 */ public PoissonDistributionImpl(double p) { this(p, new NormalDistributionImpl()); }
/** * Create a new normal distribution with the mean zero and standard * deviation one. * * @return a new normal distribution */ public NormalDistribution createNormalDistribution() { return new NormalDistributionImpl(); }
/** * Create a new Poisson distribution with the given the mean. The mean value * must be positive; otherwise an <code>IllegalArgument</code> is thrown. * * @param p the Poisson mean * @throws IllegalArgumentException if p ≤ 0 */ public PoissonDistributionImpl(double p) { this(p, new NormalDistributionImpl()); }
/** * Create a new Poisson distribution with the given the mean. * The mean value must be positive; otherwise an * <code>IllegalArgument</code> is thrown. * * @param p the Poisson mean * @throws IllegalArgumentException if p ≤ 0 */ public PoissonDistributionImpl(double p) { this(p, new NormalDistributionImpl()); }
/** * Create a new normal distribution with the given mean and standard * deviation. * * @param mean the mean of the distribution * @param sd standard deviation * @return a new normal distribution */ public NormalDistribution createNormalDistribution(double mean, double sd) { return new NormalDistributionImpl(mean, sd); }
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)); } }
/** * Computes the significance of the difference between two correlations. * @see org.tud.sir.util.statistics.Significance.testCorrelations */ public static double getSignificance(double correlation1, double correlation2, int n1, int n2) throws MathException { // transform to Fisher Z-values double zv1 = getZValue(correlation1); double zv2 = getZValue(correlation2); // difference of the Z-values double zDifference = (zv1 - zv2) / Math.sqrt( (double)1/(n1-3) + (double)1/(n2-3)); // get p value from the normal distribution NormalDistribution normal = new NormalDistributionImpl(); double p = 2 * (1 - normal.cumulativeProbability( Math.abs(zDifference))); return p; }
public synchronized Double computePhiMeasure(long now) { if (latestHeartbeatMs == -1 || descriptiveStatistics.getN() < minimumSamples) { return null; } long delta = now - latestHeartbeatMs; try { double probability; if (distribution.equals("normal")) { double standardDeviation = descriptiveStatistics.getStandardDeviation(); standardDeviation = standardDeviation < 0.1 ? 0.1 : standardDeviation; probability = new NormalDistributionImpl(descriptiveStatistics.getMean(), standardDeviation).cumulativeProbability(delta); } else { probability = new ExponentialDistributionImpl(descriptiveStatistics.getMean()).cumulativeProbability(delta); } final double eps = 1e-12; if (1 - probability < eps) { probability = 1.0; } return -1.0d * Math.log10(1.0d - probability); } catch (MathException | IllegalArgumentException e) { LOGGER.debug(e); return null; } } }