Class GammaDistribution
java.lang.Object
cloud.opencode.base.math.distribution.GammaDistribution
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 TypeMethodDescriptiondoublecdf(double x) Computes the cumulative distribution function (CDF) at x.doubleinverseCdf(double p) Computes the inverse CDF (quantile function).doublemean()Returns the mean of this distribution: shape * scale.static GammaDistributionof(double shape, double scale) Creates a Gamma distribution with the specified shape and scale.doublepdf(double x) Computes the probability density function (PDF) at x.doublescale()Returns the scale parameter.doubleshape()Returns the shape parameter.toString()doublevariance()Returns the variance of this distribution: shape * scale^2.
-
Method Details
-
of
Creates a Gamma distribution with the specified shape and scale. 创建具有指定形状和尺度的 Gamma 分布- Parameters:
shape- the shape parameter (k or alpha), must be > 0 / 形状参数,必须 > 0scale- 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
-