Class GammaDistribution

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

public final class GammaDistribution extends Object
Immutable Gamma distribution. 不可变 Gamma 分布

Provides PDF, CDF, inverse CDF (quantile function), mean, and variance. Thread-safe: instances are immutable.

提供概率密度函数、累积分布函数、逆累积分布函数(分位函数)、均值和方差。 线程安全:实例不可变。

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: shape * scale.
    of(double shape, double scale)
    Creates a Gamma distribution with the specified shape and scale.
    double
    pdf(double x)
    Computes the probability density function (PDF) at x.
    double
    Returns the scale parameter.
    double
    Returns the shape parameter.
     
    double
    Returns the variance of this distribution: shape * scale^2.

    Methods inherited from class Object

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

    • of

      public static GammaDistribution of(double shape, double scale)
      Creates a Gamma distribution with the specified shape and scale. 创建具有指定形状和尺度的 Gamma 分布
      Parameters:
      shape - the shape parameter (k or alpha), must be > 0 / 形状参数,必须 > 0
      scale - the scale parameter (theta), must be > 0 / 尺度参数,必须 > 0
      Returns:
      a new GammaDistribution instance / 新的 Gamma 分布实例
      Throws:
      IllegalArgumentException - if shape or scale ≤ 0 or not finite
    • shape

      public double shape()
      Returns the shape parameter. 返回形状参数
      Returns:
      the shape parameter / 形状参数
    • scale

      public double scale()
      Returns the scale parameter. 返回尺度参数
      Returns:
      the scale parameter / 尺度参数
    • mean

      public double mean()
      Returns the mean of this distribution: shape * scale. 返回此分布的均值:shape * scale
      Returns:
      the mean / 均值
    • variance

      public double variance()
      Returns the variance of this distribution: shape * scale^2. 返回此分布的方差:shape * scale^2
      Returns:
      the variance / 方差
    • pdf

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

      f(x) = x^(shape-1) * exp(-x/scale) / (scale^shape * Gamma(shape))

      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) = P(shape, x/scale) where P is the regularized lower incomplete gamma function.

      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). 计算逆累积分布函数(分位函数)
      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