Double result = new Double(nd.inverseCumulativeProbability(dbl)); LOGGER.debug("Inverse Normal result : " + result.doubleValue()); return result;
/** * For this disbution, X, this method returns P(X < x). * @param x the value at which the CDF is evaluated. * @return CDF for this distribution. * @throws MathException if the cumulative probability can not be * computed due to convergence or other numerical errors. */ public double cumulativeProbability(double x) throws MathException { return getGamma().cumulativeProbability(x); }
/** * 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()); }
/** * Return the domain for the given hypergeometric distribution parameters. * * @param n the population size. * @param m number of successes in the population. * @param k the sample size. * @return a two element array containing the lower and upper bounds of the * hypergeometric distribution. */ private int[] getDomain(int n, int m, int k) { return new int[] { getLowerDomain(n, m, k), getUpperDomain(m, k) }; }
/** * Create a Chi-Squared distribution with the given degrees of freedom and * inverse cumulative probability accuracy. * @param df degrees of freedom. * @param inverseCumAccuracy the maximum absolute error in inverse cumulative probability estimates * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}) * @since 2.1 */ public ChiSquaredDistributionImpl(double df, double inverseCumAccuracy) { super(); gamma = new GammaDistributionImpl(df / 2.0, 2.0); setDegreesOfFreedomInternal(df); solverAbsoluteAccuracy = inverseCumAccuracy; }
public static double criticalVal(int hashCount, double alpha) { ChiSquaredDistributionImpl d = new ChiSquaredDistributionImpl(hashCount - 1); try { return d.inverseCumulativeProbability(1 - alpha); } catch (MathException e) { return Double.MIN_VALUE; } }
/** * Access the domain value lower bound, based on <code>p</code>, used to * bracket a CDF root. This method is used by * {@link #inverseCumulativeProbability(double)} to find critical values. * * @param p the desired probability for the critical value * @return domain value lower bound, i.e. * P(X < <i>lower bound</i>) < <code>p</code> */ protected double getDomainLowerBound(double p) { return Double.MIN_VALUE * getGamma().getBeta(); }
/** * Default constructor. */ public TTestImpl() { this(new TDistributionImpl(1.0)); }
/** * Create a binomial distribution with the given number of trials and * probability of success. * * @param trials the number of trials. * @param p the probability of success. */ public BinomialDistributionImpl(int trials, double p) { super(); setNumberOfTrialsInternal(trials); setProbabilityOfSuccessInternal(p); }
/** * Returns the mean of the distribution. * * For <code>k</code> degrees of freedom, the mean is * <code>k</code> * * @return the mean * @since 2.2 */ public double getNumericalMean() { return getDegreesOfFreedom(); }
/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(double p) throws MathException { if (p == 0) { return 0; } else if (p == 1) { return 1; } else { return super.inverseCumulativeProbability(p); } }
/** * Create a Chi-Squared distribution with the given degrees of freedom. * @param df degrees of freedom. */ public ChiSquaredDistributionImpl(double df) { this(df, new GammaDistributionImpl(df / 2.0, 2.0)); }
/** * For this distribution, X, this method returns P(X < x). * @param x the value at which the CDF is evaluated. * @return CDF for this distribution. * @throws MathException if the cumulative probability can not be * computed due to convergence or other numerical errors. */ public double cumulativeProbability(double x) throws MathException { return gamma.cumulativeProbability(x); }
/** * Returns the upper bound of the support for the distribution. * * The upper bound of the support is the number of trials. * * @return upper bound of the support (equal to number of trials) * @since 2.2 */ public int getSupportUpperBound() { return getNumberOfTrials(); }
/** * Returns the mean of the distribution. * * For mean parameter <code>k</code>, the mean is * <code>k</code> * * @return the mean * @since 2.2 */ public double getNumericalMean() { return getMean(); }
/** * Create a exponential distribution with the given mean. * @param mean mean of this distribution. * @param inverseCumAccuracy the maximum absolute error in inverse cumulative probability estimates * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}) * @since 2.1 */ public ExponentialDistributionImpl(double mean, double inverseCumAccuracy) { super(); setMeanInternal(mean); solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Returns the variance of the distribution. * * For mean parameter <code>p</code>, the variance is <code>p</code> * * @return the variance * @since 2.2 */ public double getNumericalVariance() { return getMean(); }
/** * Returns the upper bound of the support for the distribution. * * The upper bound of the support is the number of elements * * @return upper bound of the support * @since 2.2 */ public int getSupportUpperBound() { return getNumberOfElements(); }