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

public Class LevyDistribution

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

This class implements the Lévy distribution.
Since
3.2

Field Summary

Modifier and TypeField and Description
private final double
c

Scale parameter.

private final double
halfC

Half of c (for calculations).

private final double
mu

Location parameter.

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

Constructor Summary

AccessConstructor and Description
public
LevyDistribution(final double
location parameter
mu
,
final double
scale parameter
c
)

Build a new instance.

public
LevyDistribution(final RandomGenerator
random generator to be used for sampling
rng
,
final double
location
mu
,
final double
scale parameter
c
)

Creates a LevyDistribution.

Method Summary

Modifier and TypeMethod and Description
public double
cumulativeProbability(final 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(final 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:

location parameter of the distribution
getLocation
()

Get the location parameter of the distribution.

public double
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
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:

scale parameter of the distribution
getScale
()

Get the scale parameter of the distribution.

public double
public double
public double
public boolean
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.

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

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

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

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

Field Detail

cback to summary
private final double c

Scale parameter.

halfCback to summary
private final double halfC

Half of c (for calculations).

muback to summary
private final double mu

Location parameter.

serialVersionUIDback to summary
private static final long serialVersionUID

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

Serializable UID.

Constructor Detail

LevyDistributionback to summary
public LevyDistribution(final double mu, final double c)

Build a new instance.

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
mu:double

location parameter

c:double

scale parameter

Since
3.4
LevyDistributionback to summary
public LevyDistribution(final RandomGenerator rng, final double mu, final double c)

Creates a LevyDistribution.

Parameters
rng:RandomGenerator

random generator to be used for sampling

mu:double

location

c:double

scale parameter

Method Detail

cumulativeProbabilityback to summary
public double cumulativeProbability(final 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.

From Wikipedia: the cumulative distribution function is

f(x; u, c) = erfc (√ (c / 2 (x - u )))
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(final 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.

From Wikipedia: The probability density function of the Lévy distribution over the domain is

f(x; μ, c) = √(c / 2π) * e-c / 2 (x - μ) / (x - μ)3/2

For this distribution, X, this method returns P(X < x). If x is less than location parameter μ, Double.NaN is returned, as in these cases the distribution is not defined.

Parameters
x:double

the point at which the PDF is evaluated

Returns:double

the value of the probability density function at point x

getLocationback to summary
public double getLocation()

Get the location parameter of the distribution.

Returns:double

location parameter of the 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.

Returns:double

the mean or Double.NaN if it is not defined

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.

Returns:double

the variance (possibly Double.POSITIVE_INFINITY as for certain cases in TDistribution) or Double.NaN if it is not defined

getScaleback to summary
public double getScale()

Get the scale parameter of the distribution.

Returns:double

scale parameter of the distribution

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}.

Returns:double

lower bound of the support (might be 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}.

Returns:double

upper bound of the support (might be Double.POSITIVE_INFINITY)

inverseCumulativeProbabilityback to summary
public double inverseCumulativeProbability(final 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
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.

Returns:boolean

whether the support is connected or not

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

logDensityback to summary
public double logDensity(double x)

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

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

Returns the natural logarithm of 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. Note that due to the floating point precision and under/overflow issues, this method will for some distributions be more precise and faster than computing the logarithm of density(double). The default implementation simply computes the logarithm of density(x). See documentation of density(double) for computation details.

Parameters
x:double

the point at which the PDF is evaluated

Returns:double

the logarithm of the value of the probability density function at point x

Annotations
@Override