Top Description Fields Constructors Methods
org.apache.commons.math3.distribution

public Class CauchyDistribution

extends AbstractRealDistribution
Class Inheritance
Imports
org.apache.commons.math3.exception.NotStrictlyPositiveException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.random.RandomGenerator, .Well19937c, org.apache.commons.math3.util.FastMath

Implementation of the Cauchy distribution.
Since
1.1 (changed to concrete class in 3.0)
See Also
Cauchy distribution (Wikipedia), Cauchy Distribution (MathWorld)

Field Summary

Modifier and TypeField and Description
public static final double
DEFAULT_INVERSE_ABSOLUTE_ACCURACY

Default inverse cumulative probability accuracy.

private final double
median

The median of this distribution.

private final double
scale

The scale of this distribution.

private static final long
private final double
Inherited from org.apache.commons.math3.distribution.AbstractRealDistribution:
randomrandomDataSOLVER_DEFAULT_ABSOLUTE_ACCURACY

Constructor Summary

AccessConstructor and Description
public
CauchyDistribution()

Creates a Cauchy distribution with the median equal to zero and scale equal to one.

public
CauchyDistribution(double
Median for this distribution.
median
,
double
Scale parameter for this distribution.
scale
)

Creates a Cauchy distribution using the given median and scale.

public
CauchyDistribution(double
Median for this distribution.
median
,
double
Scale parameter for this distribution.
scale
,
double
Maximum absolute error in inverse cumulative probability estimates (defaults to DEFAULT_INVERSE_ABSOLUTE_ACCURACY).
inverseCumAccuracy
)

Creates a Cauchy distribution using the given median and scale.

public
CauchyDistribution(RandomGenerator
Random number generator.
rng
,
double
Median for this distribution.
median
,
double
Scale parameter for this distribution.
scale
)

Creates a Cauchy distribution.

public
CauchyDistribution(RandomGenerator
Random number generator.
rng
,
double
Median for this distribution.
median
,
double
Scale parameter for this distribution.
scale
,
double
Maximum absolute error in inverse cumulative probability estimates (defaults to DEFAULT_INVERSE_ABSOLUTE_ACCURACY).
inverseCumAccuracy
)

Creates a Cauchy distribution.

Method Summary

Modifier and TypeMethod and Description
public double
cumulativeProbability(double
the point at which the CDF is evaluated
x
)

Implements org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

For a random variable X whose values are distributed according to this distribution, this method returns P(X <= x).

public double
density(double
the point at which the PDF is evaluated
x
)

Implements org.apache.commons.math3.distribution.RealDistribution.density.

Returns the probability density function (PDF) of this distribution evaluated at the specified point x.

public double

Returns:

the median for this distribution.
getMedian
()

Access the median.

public double

Returns:

mean (always Double.NaN)
getNumericalMean
()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalMean.

Use this method to get the numerical value of the mean of this distribution.

public double

Returns:

variance (always Double.NaN)
getNumericalVariance
()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalVariance.

Use this method to get the numerical value of the variance of this distribution.

public double

Returns:

the scale parameter for this distribution.
getScale
()

Access the scale parameter.

protected double
getSolverAbsoluteAccuracy()

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.getSolverAbsoluteAccuracy.

Returns the solver absolute accuracy for inverse cumulative computation.

public double

Returns:

lower bound of the support (always Double.NEGATIVE_INFINITY)
getSupportLowerBound
()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportLowerBound.

Access the lower bound of the support.

public double

Returns:

upper bound of the support (always Double.POSITIVE_INFINITY)
getSupportUpperBound
()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportUpperBound.

Access the upper bound of the support.

public double
public boolean

Returns:

true
isSupportConnected
()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportConnected.

Use this method to get information about whether the support is connected, i.e. whether all values between the lower and upper bound of the support are included in the support.

public boolean
isSupportLowerBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportLowerBoundInclusive.

Whether or not the lower bound of support is in the domain of the density function.

public boolean
isSupportUpperBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportUpperBoundInclusive.

Whether or not the upper bound of support is in the domain of the density function.

Inherited from org.apache.commons.math3.distribution.AbstractRealDistribution:
cumulativeProbabilitylogDensityprobabilityprobabilityreseedRandomGeneratorsamplesample

Field Detail

DEFAULT_INVERSE_ABSOLUTE_ACCURACYback to summary
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY

Default inverse cumulative probability accuracy.

Since
2.1
medianback to summary
private final double median

The median of this distribution.

scaleback to summary
private final double scale

The scale of this distribution.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.math3.distribution.AbstractRealDistribution.serialVersionUID.

Serializable version identifier

solverAbsoluteAccuracyback to summary
private final double solverAbsoluteAccuracy

Hides org.apache.commons.math3.distribution.AbstractRealDistribution.solverAbsoluteAccuracy.

Inverse cumulative probability accuracy

Constructor Detail

CauchyDistributionback to summary
public CauchyDistribution()

Creates a Cauchy distribution with the median equal to zero and scale equal to one.

CauchyDistributionback to summary
public CauchyDistribution(double median, double scale)

Creates a Cauchy distribution using the given median and scale.

Note

this constructor will implicitly create an instance of Well19937c as random generator to be used for sampling only (see sample() and sample(int)). In case no sampling is needed for the created distribution, it is advised to pass null as random generator via the appropriate constructors to avoid the additional initialisation overhead.

Parameters
median:double

Median for this distribution.

scale:double

Scale parameter for this distribution.

CauchyDistributionback to summary
public CauchyDistribution(double median, double scale, double inverseCumAccuracy)

Creates a Cauchy distribution using the given median and scale.

Note

this constructor will implicitly create an instance of Well19937c as random generator to be used for sampling only (see sample() and sample(int)). In case no sampling is needed for the created distribution, it is advised to pass null as random generator via the appropriate constructors to avoid the additional initialisation overhead.

Parameters
median:double

Median for this distribution.

scale:double

Scale parameter for this distribution.

inverseCumAccuracy:double

Maximum absolute error in inverse cumulative probability estimates (defaults to DEFAULT_INVERSE_ABSOLUTE_ACCURACY).

Exceptions
NotStrictlyPositiveException:
if scale <= 0.
Since
2.1
CauchyDistributionback to summary
public CauchyDistribution(RandomGenerator rng, double median, double scale)

Creates a Cauchy distribution.

Parameters
rng:RandomGenerator

Random number generator.

median:double

Median for this distribution.

scale:double

Scale parameter for this distribution.

Exceptions
NotStrictlyPositiveException:
if scale <= 0.
Since
3.3
CauchyDistributionback to summary
public CauchyDistribution(RandomGenerator rng, double median, double scale, double inverseCumAccuracy)

Creates a Cauchy distribution.

Parameters
rng:RandomGenerator

Random number generator.

median:double

Median for this distribution.

scale:double

Scale parameter for this distribution.

inverseCumAccuracy:double

Maximum absolute error in inverse cumulative probability estimates (defaults to DEFAULT_INVERSE_ABSOLUTE_ACCURACY).

Exceptions
NotStrictlyPositiveException:
if scale <= 0.
Since
3.1

Method Detail

cumulativeProbabilityback to summary
public double cumulativeProbability(double x)

Implements org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

Doc from org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

For a random variable X whose values are distributed according to this distribution, this method returns P(X <= x). In other words, this method represents the (cumulative) distribution function (CDF) for this distribution.

Parameters
x:double

the point at which the CDF is evaluated

Returns:double

the probability that a random variable with this distribution takes a value less than or equal to x

densityback to summary
public double density(double x)

Implements org.apache.commons.math3.distribution.RealDistribution.density.

Doc from org.apache.commons.math3.distribution.RealDistribution.density.

Returns the probability density function (PDF) of this distribution evaluated at the specified point x. In general, the PDF is the derivative of the CDF. If the derivative does not exist at x, then an appropriate replacement should be returned, e.g. Double.POSITIVE_INFINITY, Double.NaN, or the limit inferior or limit superior of the difference quotient.

Parameters
x:double

the point at which the PDF is evaluated

Returns:double

the value of the probability density function at point x

getMedianback to summary
public double getMedian()

Access the median.

Returns:double

the median for this distribution.

getNumericalMeanback to summary
public double getNumericalMean()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalMean.

Doc from org.apache.commons.math3.distribution.RealDistribution.getNumericalMean.

Use this method to get the numerical value of the mean of this distribution. The mean is always undefined no matter the parameters.

Returns:double

mean (always Double.NaN)

getNumericalVarianceback to summary
public double getNumericalVariance()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalVariance.

Doc from org.apache.commons.math3.distribution.RealDistribution.getNumericalVariance.

Use this method to get the numerical value of the variance of this distribution. The variance is always undefined no matter the parameters.

Returns:double

variance (always Double.NaN)

getScaleback to summary
public double getScale()

Access the scale parameter.

Returns:double

the scale parameter for this distribution.

getSolverAbsoluteAccuracyback to summary
protected double getSolverAbsoluteAccuracy()

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.getSolverAbsoluteAccuracy.

Doc from org.apache.commons.math3.distribution.AbstractRealDistribution.getSolverAbsoluteAccuracy.

Returns the solver absolute accuracy for inverse cumulative computation. You can override this method in order to use a Brent solver with an absolute accuracy different from the default.

Returns:double

the maximum absolute error in inverse cumulative probability estimates

Annotations
@Override
getSupportLowerBoundback to summary
public double getSupportLowerBound()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportLowerBound.

Doc from org.apache.commons.math3.distribution.RealDistribution.getSupportLowerBound.

Access the lower bound of the support. This method must return the same value as inverseCumulativeProbability(0). In other words, this method must return

inf {x in R | P(X <= x) > 0}.

The lower bound of the support is always negative infinity no matter the parameters.
Returns:double

lower bound of the support (always Double.NEGATIVE_INFINITY)

getSupportUpperBoundback to summary
public double getSupportUpperBound()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportUpperBound.

Doc from org.apache.commons.math3.distribution.RealDistribution.getSupportUpperBound.

Access the upper bound of the support. This method must return the same value as inverseCumulativeProbability(1). In other words, this method must return

inf {x in R | P(X <= x) = 1}.

The upper bound of the support is always positive infinity no matter the parameters.
Returns:double

upper bound of the support (always Double.POSITIVE_INFINITY)

inverseCumulativeProbabilityback to summary
public double inverseCumulativeProbability(double p) throws OutOfRangeException

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.inverseCumulativeProbability.

Implements org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

Doc from org.apache.commons.math3.distribution.AbstractRealDistribution.inverseCumulativeProbability.

Computes the quantile function of this distribution. For a random variable X distributed according to this distribution, the returned value is

  • inf{x in R | P(X<=x) >= p} for 0 < p <= 1,
  • inf{x in R | P(X<=x) > 0} for p = 0.
The default implementation returns Returns Double.NEGATIVE_INFINITY when p == 0 and Double.POSITIVE_INFINITY when p == 1.
Parameters
p:double

Doc from org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

the cumulative probability

Returns:double

Doc from org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

the smallest p-quantile of this distribution (largest 0-quantile for p = 0)

Annotations
@Override
Exceptions
OutOfRangeException:

Doc from org.apache.commons.math3.distribution.RealDistribution.inverseCumulativeProbability.

if p < 0 or p > 1

isSupportConnectedback to summary
public boolean isSupportConnected()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportConnected.

Doc from org.apache.commons.math3.distribution.RealDistribution.isSupportConnected.

Use this method to get information about whether the support is connected, i.e. whether all values between the lower and upper bound of the support are included in the support. The support of this distribution is connected.

Returns:boolean

true

isSupportLowerBoundInclusiveback to summary
public boolean isSupportLowerBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportLowerBoundInclusive.

Doc from org.apache.commons.math3.distribution.RealDistribution.isSupportLowerBoundInclusive.

Whether or not the lower bound of support is in the domain of the density function. Returns true iff getSupporLowerBound() is finite and density(getSupportLowerBound()) returns a non-NaN, non-infinite value.

Returns:boolean

true if the lower bound of support is finite and the density function returns a non-NaN, non-infinite value there

isSupportUpperBoundInclusiveback to summary
public boolean isSupportUpperBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportUpperBoundInclusive.

Doc from org.apache.commons.math3.distribution.RealDistribution.isSupportUpperBoundInclusive.

Whether or not the upper bound of support is in the domain of the density function. Returns true iff getSupportUpperBound() is finite and density(getSupportUpperBound()) returns a non-NaN, non-infinite value.

Returns:boolean

true if the upper bound of support is finite and the density function returns a non-NaN, non-infinite value there