LevyDistribution

class LevyDistribution(val mu: Double = 0.0, val c: Double = 1.0) : ContinuousDistribution(source)

Represents the Levy distribution, a heavy-tailed, right-skewed continuous probability distribution supported on [mu, +infinity).

The Levy distribution is one of only three stable distributions whose probability density has a closed-form expression (the other two being the normal and Cauchy distributions). It arises naturally in physics as the distribution of first-passage times of Brownian motion and is used in finance to model heavy-tailed phenomena such as extreme market movements.

The distribution is parameterized by a location parameter mu and a scale parameter c. Because the tails are extremely heavy, the mean and variance are both infinite, and the skewness and excess kurtosis are undefined (returned as Double.NaN).

The CDF and survival function are expressed in terms of the complementary error function and error function respectively, and the quantile function uses the inverse complementary error function, so no iterative root-finding is needed.

Example:

val levy = LevyDistribution(mu = 0.0, c = 1.0)
levy.mean // Infinity
levy.variance // Infinity
levy.pdf(1.0) // 0.2420 (density at x = 1)
levy.cdf(2.0) // 0.4795
levy.quantile(0.5) // 2.1981 (the median)
levy.sample(Random(42)) // a single random draw from Levy(0, 1)

// Standard Levy distribution (mu=0, c=1)
val std = LevyDistribution.STANDARD
std.cdf(1.0) // 0.3173

Constructors

Link copied to clipboard
constructor(mu: Double = 0.0, c: Double = 1.0)

Types

Link copied to clipboard
object Companion

Provides the standard Levy distribution instance.

Properties

Link copied to clipboard
val c: Double

the scale parameter, controlling the spread of the distribution. Must be positive. Default is 1.0.

Link copied to clipboard
open override val entropy: Double

The differential entropy of this distribution in nats, computed from the scale parameter c and the Euler-Mascheroni constant.

Link copied to clipboard
open override val kurtosis: Double

Returns Double.NaN because the excess kurtosis of the Levy distribution is undefined.

Link copied to clipboard
open override val mean: Double

Returns Double.POSITIVE_INFINITY because the Levy distribution has infinite mean.

Link copied to clipboard
val mu: Double

the location parameter, defining the left endpoint of the support. Default is 0.0.

Link copied to clipboard
open override val skewness: Double

Returns Double.NaN because the skewness of the Levy distribution is undefined.

Link copied to clipboard
open override val variance: Double

Returns Double.POSITIVE_INFINITY because the Levy distribution has infinite variance.

Functions

Link copied to clipboard
open override fun cdf(x: Double): Double

Computes the cumulative distribution function at x using the complementary error function.

Link copied to clipboard
open override fun logPdf(x: Double): Double

Computes the natural logarithm of the probability density at x.

Link copied to clipboard
open override fun pdf(x: Double): Double

Computes the probability density at x using the Levy density formula.

Link copied to clipboard
open override fun quantile(p: Double): Double

Computes the quantile (inverse CDF) for the given probability p using the inverse complementary error function.

Link copied to clipboard
open override fun sample(random: Random): Double

Draws a single random value from this Levy distribution using inverse CDF sampling.

Link copied to clipboard
open override fun sf(x: Double): Double

Computes the survival function at x using the error function directly.