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
    Constructor
    Description
    COptQuestGammaDistribution(double shape, double scale)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    cdf(double x)
     
    static double
    CDF(double x, double shape)
    Gamma Cumulative Distribution Function (CDF) with default scale = 1.0
    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.
    double
    chaz(double x)
     
    static double
    CHAZ(double x, double shape)
    Gamma Cumulative Hazard Function with default scale = 1.0
    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.
    double
    haz(double x)
     
    static double
    HAZ(double x, double shape)
    Gamma Hazard Function with default scale = 1.0
    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.
    double
    pdf(double x)
     
    static double
    PDF(double x, double shape)
    Gamma Probability Density Function (PDF) with default scale = 1.0
    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.
    double
    ppf(double x)
     
    static double
    PPF(double p, double shape)
    Gamma Percent Point Function (PPF) with default scale = 1.0
    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.
    double
    sf(double x)
     

    Methods inherited from class java.lang.Object

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

    • COptQuestGammaDistribution

      public COptQuestGammaDistribution(double shape, double scale)
  • 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 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 positive
      scale - 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 positive
      scale - 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 positive
      scale - 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 function
      shape - shape parameter (alpha/gamma) - must be positive
      scale - 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 function
      shape - 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 function
      shape - shape parameter (alpha/gamma) - must be positive
      scale - 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 function
      shape - shape parameter (alpha/gamma) - must be positive
      Returns:
      the cumulative hazard function value