/** * Create a new exponential distribution with the given degrees of freedom. * * @param mean mean * @return a new exponential distribution */ public ExponentialDistribution createExponentialDistribution(double mean) { return new ExponentialDistributionImpl(mean); }
/** * 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; }
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; } } }
/** * Return the probability density for a particular point. * * @param x The point at which the density should be computed. * @return The pdf at point x. * @deprecated - use density(double) */ public double density(Double x) { return density(x.doubleValue()); }
/** * Create a exponential distribution with the given mean. * @param mean mean of this distribution. */ public ExponentialDistributionImpl(double mean) { super(); setMean(mean); }
/** * Return the probability density for a particular point. * * @param x The point at which the density should be computed. * @return The pdf at point x. * @deprecated - use density(double) */ @Deprecated public double density(Double x) { return density(x.doubleValue()); }
/** * 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; }
public static ExponentialDistribution exponentialDistribution( final double mean ) { return new ExponentialDistributionImpl(mean); }
/** * 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; }
/** * 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; } }
/** * Modify the mean. * @param mean the new mean. * @throws IllegalArgumentException if <code>mean</code> is not positive. * @deprecated as of 2.1 (class will become immutable in 3.0) */ @Deprecated public void setMean(double mean) { setMeanInternal(mean); } /**
/** * 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(); } } }
/** * Modify the mean. * @param mean the new mean. * @throws IllegalArgumentException if <code>mean</code> is not positive. * @deprecated as of 2.1 (class will become immutable in 3.0) */ @Deprecated public void setMean(double mean) { setMeanInternal(mean); } /**
/** * 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; }