/** * 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(); }
/** * Returns the variance of the distribution. * * For mean parameter <code>k</code>, the variance is * <code>k^2</code> * * @return the variance * @since 2.2 */ public double getNumericalVariance() { final double m = getMean(); return m * m; }
/** * Access the domain value upper bound, based on <code>p</code>, used to * bracket a CDF root. * * @param p the desired probability for the critical value * @return domain value upper bound, i.e. * P(X < <i>upper bound</i>) > <code>p</code> */ protected double getDomainUpperBound(double p) { // NOTE: exponential is skewed to the left // NOTE: therefore, P(X < μ) > .5 if (p < .5) { // use mean return getMean(); } else { // use max return Double.MAX_VALUE; } }
/** * Access the initial domain value, based on <code>p</code>, used to * bracket a CDF root. * * @param p the desired probability for the critical value * @return initial domain value */ protected double getInitialDomain(double p) { // TODO: try to improve on this estimate // Exponential is skewed to the left, therefore, P(X < μ) > .5 if (p < .5) { // use 1/2 mean return getMean() * .5; } else { // use mean return getMean(); } } }
/** * For this disbution, X, this method returns P(X < x). * * The implementation of this method is based on: * <ul> * <li> * <a href="http://mathworld.wolfram.com/ExponentialDistribution.html"> * Exponential Distribution</a>, equation (1).</li> * </ul> * * @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{ double ret; if (x <= 0.0) { ret = 0.0; } else { ret = 1.0 - Math.exp(-x / getMean()); } return ret; }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if p < 0 or p > 1. */ public double inverseCumulativeProbability(double p) throws MathException { double ret; if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException ("probability argument must be between 0 and 1 (inclusive)"); } else if (p == 1.0) { ret = Double.POSITIVE_INFINITY; } else { ret = -getMean() * Math.log(1.0 - p); } return ret; }