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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    cdf(double x)
     
    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.
    double
    chaz(double x)
     
    double
    haz(double x)
     
    double
    pdf(double x)
     
    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.
    double
    ppf(double x)
     
    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.
    double
    sf(double x)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • COptQuestChiSquareDistribution

      public COptQuestChiSquareDistribution(double df)
  • Method Details

    • pdf

      public double pdf(double x)
      Specified by:
      pdf in interface com.opttek.optquest.IProbabilityDistribution
    • cdf

      public double cdf(double x)
      Specified by:
      cdf in interface com.opttek.optquest.IProbabilityDistribution
    • ppf

      public double ppf(double x)
      Specified by:
      ppf in interface com.opttek.optquest.IProbabilityDistribution
    • sf

      public double sf(double x)
      Specified by:
      sf in interface com.opttek.optquest.IProbabilityDistribution
    • chaz

      public double chaz(double x)
      Specified by:
      chaz in interface com.opttek.optquest.IProbabilityDistribution
    • haz

      public double haz(double x)
      Specified by:
      haz in interface com.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