Package com.opttek.optquest
Class COptQuestGammaDistribution
java.lang.Object
com.opttek.optquest.COptQuestGammaDistribution
- All Implemented Interfaces:
com.opttek.optquest.IProbabilityDistribution
public class COptQuestGammaDistribution
extends Object
implements com.opttek.optquest.IProbabilityDistribution
Class providing static methods for gamma distribution functions:
CDF, PDF, PPF (inverse CDF), hazard, and cumulative hazard.
Implementations match scipy.stats.gamma results.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecdf(double x) static doubleCDF(double x, double shape) Gamma Cumulative Distribution Function (CDF) with default scale = 1.0static doubleCDF(double x, double shape, double scale) Gamma Cumulative Distribution Function (CDF) Computes P(X ≤ x) where X follows a gamma distribution with given shape and scale parameters.doublechaz(double x) static doubleCHAZ(double x, double shape) Gamma Cumulative Hazard Function with default scale = 1.0static doubleCHAZ(double x, double shape, double scale) Gamma Cumulative Hazard Function Computes the cumulative hazard function H(x) = -ln(1 - F(x)) = -ln(S(x)) where S(x) is the survival function.doublehaz(double x) static doubleHAZ(double x, double shape) Gamma Hazard Function with default scale = 1.0static doubleHAZ(double x, double shape, double scale) Gamma Hazard Function Computes the hazard function h(x) = f(x) / (1 - F(x)) = PDF(x) / (1 - CDF(x)) where f(x) is the PDF and F(x) is the CDF.doublepdf(double x) static doublePDF(double x, double shape) Gamma Probability Density Function (PDF) with default scale = 1.0static doublePDF(double x, double shape, double scale) Gamma Probability Density Function (PDF) Computes the probability density at x for a gamma distribution with given shape and scale parameters.doubleppf(double x) static doublePPF(double p, double shape) Gamma Percent Point Function (PPF) with default scale = 1.0static doublePPF(double p, double shape, double scale) Gamma Percent Point Function (PPF) - Inverse CDF Computes the value x such that P(X ≤ x) = p, where X follows a gamma distribution with given shape and scale parameters.doublesf(double x)
-
Constructor Details
-
COptQuestGammaDistribution
public COptQuestGammaDistribution(double shape, double scale)
-
-
Method Details
-
pdf
public double pdf(double x) - Specified by:
pdfin interfacecom.opttek.optquest.IProbabilityDistribution
-
cdf
public double cdf(double x) - Specified by:
cdfin interfacecom.opttek.optquest.IProbabilityDistribution
-
ppf
public double ppf(double x) - Specified by:
ppfin interfacecom.opttek.optquest.IProbabilityDistribution
-
sf
public double sf(double x) - Specified by:
sfin interfacecom.opttek.optquest.IProbabilityDistribution
-
chaz
public double chaz(double x) - Specified by:
chazin interfacecom.opttek.optquest.IProbabilityDistribution
-
haz
public double haz(double x) - Specified by:
hazin interfacecom.opttek.optquest.IProbabilityDistribution
-
CDF
public static double CDF(double x, double shape, double scale) Gamma Cumulative Distribution Function (CDF) Computes P(X ≤ x) where X follows a gamma distribution with given shape and scale parameters. Uses the regularized incomplete gamma function for computation.- Parameters:
x- the value at which to evaluate the CDF (must be non-negative)shape- shape parameter (alpha/gamma) - must be positivescale- scale parameter (beta) - must be positive- Returns:
- the cumulative probability P(X ≤ x)
-
CDF
public static double CDF(double x, double shape) Gamma Cumulative Distribution Function (CDF) with default scale = 1.0- Parameters:
x- the value at which to evaluate the CDF (must be non-negative)shape- shape parameter (alpha/gamma) - must be positive- Returns:
- the cumulative probability P(X ≤ x)
-
PDF
public static double PDF(double x, double shape, double scale) Gamma Probability Density Function (PDF) Computes the probability density at x for a gamma distribution with given shape and scale parameters. Formula: f(x; α, β) = (1/(β^α * Γ(α))) * x^(α-1) * exp(-x/β)- Parameters:
x- the value at which to evaluate the PDF (must be non-negative)shape- shape parameter (alpha/gamma) - must be positivescale- scale parameter (beta) - must be positive- Returns:
- the probability density at x
-
PDF
public static double PDF(double x, double shape) Gamma Probability Density Function (PDF) with default scale = 1.0- Parameters:
x- the value at which to evaluate the PDF (must be non-negative)shape- shape parameter (alpha/gamma) - must be positive- Returns:
- the probability density at x
-
PPF
public static double PPF(double p, double shape, double scale) Gamma Percent Point Function (PPF) - Inverse CDF Computes the value x such that P(X ≤ x) = p, where X follows a gamma distribution with given shape and scale parameters. Uses Wilson-Hilferty transformation for initial guess when shape ≥ 15, then applies Newton-Raphson iteration with adaptive step sizing. Falls back to bisection method if Newton-Raphson fails to converge.- Parameters:
p- the probability (must be between 0 and 1, exclusive)shape- shape parameter (alpha/gamma) - must be positivescale- scale parameter (beta) - must be positive- Returns:
- the value x such that CDF(x, shape, scale) = p
-
PPF
public static double PPF(double p, double shape) Gamma Percent Point Function (PPF) with default scale = 1.0- Parameters:
p- the probability (must be between 0 and 1, exclusive)shape- shape parameter (alpha/gamma) - must be positive- Returns:
- the value x such that CDF(x, shape) = p
-
HAZ
public static double HAZ(double x, double shape, double scale) Gamma Hazard Function Computes the hazard function h(x) = f(x) / (1 - F(x)) = PDF(x) / (1 - CDF(x)) where f(x) is the PDF and F(x) is the CDF.- Parameters:
x- the value at which to evaluate the hazard functionshape- shape parameter (alpha/gamma) - must be positivescale- scale parameter (beta) - must be positive- Returns:
- the hazard function value
-
HAZ
public static double HAZ(double x, double shape) Gamma Hazard Function with default scale = 1.0- Parameters:
x- the value at which to evaluate the hazard functionshape- shape parameter (alpha/gamma) - must be positive- Returns:
- the hazard function value
-
CHAZ
public static double CHAZ(double x, double shape, double scale) Gamma Cumulative Hazard Function Computes the cumulative hazard function H(x) = -ln(1 - F(x)) = -ln(S(x)) where S(x) is the survival function.- Parameters:
x- the value at which to evaluate the cumulative hazard functionshape- shape parameter (alpha/gamma) - must be positivescale- scale parameter (beta) - must be positive- Returns:
- the cumulative hazard function value
-
CHAZ
public static double CHAZ(double x, double shape) Gamma Cumulative Hazard Function with default scale = 1.0- Parameters:
x- the value at which to evaluate the cumulative hazard functionshape- shape parameter (alpha/gamma) - must be positive- Returns:
- the cumulative hazard function value
-