Package com.opttek.optquest
Class COptQuestChiSquareDistribution
java.lang.Object
com.opttek.optquest.COptQuestChiSquareDistribution
- All Implemented Interfaces:
com.opttek.optquest.IProbabilityDistribution
public class COptQuestChiSquareDistribution
extends Object
implements com.opttek.optquest.IProbabilityDistribution
Provides methods for the Chi-Square distribution: CDF, PDF, and PPF.
Verified to match scipy.stats.chi2.
Inspired by / Based on NIST's DataPlot implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecdf(double x) static doubleCDF(double x, double df) Chi-Square Cumulative Distribution Function (CDF) Computes P(X ≤ x) where X follows a chi-square distribution with df degrees of freedom.doublechaz(double x) doublehaz(double x) doublepdf(double x) static doublePDF(double x, double df) Chi-Square Probability Density Function (PDF) Computes the probability density at x for a chi-square distribution with df degrees of freedom.doubleppf(double x) static doublePPF(double p, double df) Chi-Square Percent Point Function (PPF) - Inverse CDF Computes the value x such that P(X ≤ x) = p, where X follows a chi-square distribution with df degrees of freedom.doublesf(double x)
-
Constructor Details
-
COptQuestChiSquareDistribution
public COptQuestChiSquareDistribution(double df)
-
-
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 df) Chi-Square Cumulative Distribution Function (CDF) Computes P(X ≤ x) where X follows a chi-square distribution with df degrees of freedom. Uses the relationship: CDF(x, df) = P(df/2, x/2) where P is the regularized incomplete gamma function.- Parameters:
x- the value at which to evaluate the CDF (must be non-negative)df- degrees of freedom (must be positive)- Returns:
- the cumulative probability P(X ≤ x)
-
PDF
public static double PDF(double x, double df) Chi-Square Probability Density Function (PDF) Computes the probability density at x for a chi-square distribution with df degrees of freedom. Formula: f(x; k) = (1/(2^(k/2) * Γ(k/2))) * x^(k/2-1) * exp(-x/2)- Parameters:
x- the value at which to evaluate the PDF (must be non-negative)df- degrees of freedom (must be positive)- Returns:
- the probability density at x
-
PPF
public static double PPF(double p, double df) Chi-Square Percent Point Function (PPF) - Inverse CDF Computes the value x such that P(X ≤ x) = p, where X follows a chi-square distribution with df degrees of freedom. Uses Wilson-Hilferty transformation for initial guess when df ≥ 30, 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)df- degrees of freedom (must be positive)- Returns:
- the value x such that CDF(x, df) = p
-