edu.northwestern.at.utils.math.distributions

## Class ChiSquare

- java.lang.Object
- - edu.northwestern.at.utils.math.distributions.ChiSquare

-     public class ChiSquare
      extends java.lang.Object

  Chi-square distribution functions.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ChiSquare()` Make class non-instantiable but inheritable.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static double` | `chisquare(double chisq, double df)` Compute probability for chi-square distribution.
    `static double` | `chisquareInverse(double p, double df)` Compute percentage point for chi-square distribution.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ChiSquare

          protected ChiSquare()

      Make class non-instantiable but inheritable.

  - ### Method Detail

    - #### chisquare

          public static double chisquare(double chisq,
                         double df)

      Compute probability for chi-square distribution.
      Parameters:
        `chisq` - Percentage point of chi-square distribution
        `df` - Degrees of freedom
      Returns:
        The corresponding probabiity for the chi-square distribution.

        The probability is determined using the relationship between the incomplete gamma CDF and the chi-square distribution:

        chisqprob(chisq,df) = incompleteGamma( chisq/2, df/2 )

        The result is accurate to about 14 decimal digits.

    - #### chisquareInverse

          public static double chisquareInverse(double p,
                                double df)

      Compute percentage point for chi-square distribution.
      Parameters:
        `p` - Probability level for which to compute percentage point
        `df` - Degrees of freedom
      Returns:
        The corresponding percentage for the chi-square distribution.
      Throws:
        `java.lang.IllegalArgumentException` - If df <= 0 or p very near zero or p very near one. A tolerance of 1.0e-15 is used for testing the value of p.

        Implements the method of Best and Roberts (1975). The result accuracy varies, but should be good to at least 10 decimal digits in all cases.