/** * Create a new cauchy distribution with the given median and scale. * @param median the median of the distribution * @param scale the scale * @return a new cauchy distribution * @since 1.1 */ public CauchyDistribution createCauchyDistribution( double median, double scale) { return new CauchyDistributionImpl(median, scale); }
/** * Create a cauchy distribution using the given median and scale. * @param median median for this distribution * @param s scale parameter for this distribution * @param inverseCumAccuracy the maximum absolute error in inverse cumulative probability estimates * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}) * @since 2.1 */ public CauchyDistributionImpl(double median, double s, double inverseCumAccuracy) { super(); setMedianInternal(median); setScaleInternal(s); solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Access the initial domain value, 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 initial domain value */ protected double getInitialDomain(double p) { double ret; if (p < .5) { ret = getMedian() - getScale(); } else if (p > .5) { ret = getMedian() + getScale(); } else { ret = getMedian(); } return ret; } }
/** * Modify the median. * @param median for this distribution * @deprecated as of 2.1 (class will become immutable in 3.0) */ @Deprecated public void setMedian(double median) { setMedianInternal(median); }
/** * Modify the scale parameter. * @param s scale parameter for this distribution * @throws IllegalArgumentException if <code>sd</code> is not positive. * @deprecated as of 2.1 (class will become immutable in 3.0) */ @Deprecated public void setScale(double s) { setScaleInternal(s); }
/** * Access the domain value upper 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 upper bound, i.e. * P(X < <i>upper bound</i>) > <code>p</code> */ protected double getDomainUpperBound(double p) { double ret; if (p < .5) { ret = getMedian(); } else { ret = Double.MAX_VALUE; } return ret; }
/** * Modify the median. * @param median for this distribution * @deprecated as of 2.1 (class will become immutable in 3.0) */ @Deprecated public void setMedian(double median) { setMedianInternal(median); } /**
/** * Modify the scale parameter. * @param s scale parameter for this distribution * @throws IllegalArgumentException if <code>sd</code> is not positive. * @deprecated as of 2.1 (class will become immutable in 3.0) */ @Deprecated public void setScale(double s) { setScaleInternal(s); } /**
/** * 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) { double ret; if (p < .5) { ret = -Double.MAX_VALUE; } else { ret = getMedian(); } return ret; }
/** * Create a cauchy distribution using the given median and scale. * @param median median for this distribution * @param s scale parameter for this distribution * @param inverseCumAccuracy the maximum absolute error in inverse cumulative probability estimates * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}) * @since 2.1 */ public CauchyDistributionImpl(double median, double s, double inverseCumAccuracy) { super(); setMedianInternal(median); setScaleInternal(s); solverAbsoluteAccuracy = inverseCumAccuracy; }
/** * Generates a random value from the {@link CauchyDistributionImpl Cauchy Distribution}. * This implementation uses {@link #nextInversionDeviate(ContinuousDistribution) inversion} * to generate random values. * * @param median the median of the Cauchy distribution * @param scale the scale parameter of the Cauchy distribution * @return random value sampled from the Cauchy(median, scale) distribution * @throws MathException if an error occurs generating the random value * @since 2.2 */ public double nextCauchy(double median, double scale) throws MathException { return nextInversionDeviate(new CauchyDistributionImpl(median, scale)); }