Class LogNormalDistribution

java.lang.Object
cloud.opencode.base.math.distribution.LogNormalDistribution

public final class LogNormalDistribution extends Object
Immutable log-normal distribution. 不可变对数正态分布

A random variable X follows a log-normal distribution if ln(X) is normally distributed with mean mu and standard deviation sigma. Provides PDF, CDF, inverse CDF (quantile function), mean, and variance. Thread-safe: instances are immutable.

若 ln(X) 服从均值为 mu、标准差为 sigma 的正态分布,则随机变量 X 服从对数正态分布。 提供概率密度函数、累积分布函数、逆累积分布函数(分位函数)、均值和方差。 线程安全:实例不可变。

Since:
JDK 25, opencode-base-math V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    cdf(double x)
    Computes the cumulative distribution function (CDF) at x.
    double
    inverseCdf(double p)
    Computes the inverse CDF (quantile function).
    double
    Returns the mean of this distribution: exp(mu + sigma^2 / 2).
    double
    mu()
    Returns the mu parameter (mean of the log).
    of(double mu, double sigma)
    Creates a log-normal distribution with the specified parameters.
    double
    pdf(double x)
    Computes the probability density function (PDF) at x.
    double
    Returns the sigma parameter (standard deviation of the log).
     
    double
    Returns the variance of this distribution: (exp(sigma^2) - 1) * exp(2*mu + sigma^2).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • of

      public static LogNormalDistribution of(double mu, double sigma)
      Creates a log-normal distribution with the specified parameters. 创建具有指定参数的对数正态分布
      Parameters:
      mu - the mean of the underlying normal distribution / 底层正态分布的均值
      sigma - the standard deviation of the underlying normal distribution, must be > 0 / 底层正态分布的标准差,必须 > 0
      Returns:
      a new LogNormalDistribution instance / 新的对数正态分布实例
      Throws:
      IllegalArgumentException - if sigma ≤ 0 or parameters are not finite
    • mu

      public double mu()
      Returns the mu parameter (mean of the log). 返回 mu 参数(对数的均值)
      Returns:
      mu / mu 参数
    • sigma

      public double sigma()
      Returns the sigma parameter (standard deviation of the log). 返回 sigma 参数(对数的标准差)
      Returns:
      sigma / sigma 参数
    • mean

      public double mean()
      Returns the mean of this distribution: exp(mu + sigma^2 / 2). 返回此分布的均值:exp(mu + sigma^2 / 2)
      Returns:
      the mean / 均值
    • variance

      public double variance()
      Returns the variance of this distribution: (exp(sigma^2) - 1) * exp(2*mu + sigma^2). 返回此分布的方差:(exp(sigma^2) - 1) * exp(2*mu + sigma^2)
      Returns:
      the variance / 方差
    • pdf

      public double pdf(double x)
      Computes the probability density function (PDF) at x. 计算在 x 处的概率密度函数值

      f(x) = 1 / (x * sigma * sqrt(2*pi)) * exp(-(ln(x) - mu)^2 / (2*sigma^2))

      Parameters:
      x - the point at which to evaluate the PDF / 计算 PDF 的点
      Returns:
      the density at x / x 处的密度值
    • cdf

      public double cdf(double x)
      Computes the cumulative distribution function (CDF) at x. 计算在 x 处的累积分布函数值

      F(x) = 0.5 * erfc(-(ln(x) - mu) / (sigma * sqrt(2)))

      Parameters:
      x - the point at which to evaluate the CDF / 计算 CDF 的点
      Returns:
      the cumulative probability P(X ≤ x) / 累积概率
    • inverseCdf

      public double inverseCdf(double p)
      Computes the inverse CDF (quantile function). 计算逆累积分布函数(分位函数)

      Since ln(X) ~ N(mu, sigma), the quantile is exp(mu + sigma * z_p) where z_p is the standard normal quantile. This uses bisection for robustness.

      Parameters:
      p - the cumulative probability, must be in (0, 1) / 累积概率,必须在 (0, 1) 内
      Returns:
      the quantile x such that P(X ≤ x) = p / 使得 P(X ≤ x) = p 的分位数
      Throws:
      MathException - if p is not in (0, 1)
    • toString

      public String toString()
      Overrides:
      toString in class Object