Double result = new Double(nd.inverseCumulativeProbability(dbl)); LOGGER.debug("Inverse Normal result : " + result.doubleValue()); return result;
/** * Calculates the Poisson distribution function using a normal * approximation. The <code>N(mean, sqrt(mean))</code> distribution is used * to approximate the Poisson distribution. * <p> * The computation uses "half-correction" -- evaluating the normal * distribution function at <code>x + 0.5</code> * </p> * * @param x the upper bound, inclusive * @return the distribution function value calculated using a normal * approximation * @throws MathException if an error occurs computing the normal * approximation */ public double normalApproximateProbability(int x) throws MathException { // calculate the probability using half-correction return normal.cumulativeProbability(x + 0.5); }
/** * Set the Poisson mean for the distribution. * The mean value must be positive; otherwise an * <code>IllegalArgument</code> is thrown. * * @param p the Poisson mean value * @throws IllegalArgumentException if p ≤ 0 */ public void setMean(double p) { if (p <= 0) { throw new IllegalArgumentException( "The Poisson mean must be positive"); } this.mean = p; normal.setMean(p); normal.setStandardDeviation(Math.sqrt(p)); }
/** * Calculates the Poisson distribution function using a normal * approximation. The <code>N(mean, sqrt(mean))</code> * distribution is used to approximate the Poisson distribution. * <p> * The computation uses "half-correction" -- evaluating the normal * distribution function at <code>x + 0.5</code></p> * * @param x the upper bound, inclusive * @return the distribution function value calculated using a normal approximation * @throws MathException if an error occurs computing the normal approximation */ public double normalApproximateProbability(int x) throws MathException { // calculate the probability using half-correction return normal.cumulativeProbability(x + 0.5); }
/** * Set the Poisson mean for the distribution. The mean value must be * positive; otherwise an <code>IllegalArgument</code> is thrown. * * @param z the new distribution * @param p the Poisson mean value * @throws IllegalArgumentException if p ≤ 0 */ private void setNormalAndMeanInternal(NormalDistribution z, double p) { if (p <= 0) { throw MathRuntimeException.createIllegalArgumentException( "the Poisson mean must be positive ({0})", p); } mean = p; normal = z; normal.setMean(p); normal.setStandardDeviation(Math.sqrt(p)); }
/** * Calculates the Poisson distribution function using a normal * approximation. The <code>N(mean, sqrt(mean))</code> distribution is used * to approximate the Poisson distribution. * <p> * The computation uses "half-correction" -- evaluating the normal * distribution function at <code>x + 0.5</code> * </p> * * @param x the upper bound, inclusive * @return the distribution function value calculated using a normal * approximation * @throws MathException if an error occurs computing the normal * approximation */ public double normalApproximateProbability(int x) throws MathException { // calculate the probability using half-correction return normal.cumulativeProbability(x + 0.5); }
/** * Set the Poisson mean for the distribution. The mean value must be * positive; otherwise an <code>IllegalArgument</code> is thrown. * * @param z the new distribution * @param p the Poisson mean value * @throws IllegalArgumentException if p ≤ 0 */ private void setNormalAndMeanInternal(NormalDistribution z, double p) { if (p <= 0) { throw MathRuntimeException.createIllegalArgumentException( LocalizedFormats.NOT_POSITIVE_POISSON_MEAN, p); } mean = p; normal = z; normal.setMean(p); normal.setStandardDeviation(FastMath.sqrt(p)); }
public double pval(double val){ try { return 2 * (1 - distribution.cumulativeProbability(val)); } catch (MathException e) { throw new RuntimeException(e); } }
/** * 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; }