Class ChiSquareDistr

java.lang.Object
org.bzdev.math.stats.ProbDistribution
org.bzdev.math.stats.ChiSquareDistr
All Implemented Interfaces:
RealValuedDomainOps

public class ChiSquareDistr extends ProbDistribution
Class providing methods for the χ2 distribution.

The χ2 distribution is the distribution of the sum of the squares of k independent random variables, each with a normal distribution and with unit variances. For the default statistic, the means of these variables are zero. For a noncentral statistic, the means are nonzero.

The use of A, P and Q follows the convention in Abramowitz and Stegun, "Handbook of Mathematical Functions" (10th printing [1972], 9th Dover printing), chapter 26. Some of the methods have names that start with an upper-case letter, contrary to the usual Java convention, in order to conform to this text.

For non-central χ2 distributions, the the notation in Abramowitz and Stegun (See Equation 26.4.25) is followed. This corresponds to the case where, when there are k degrees of freedom, $\mu_i$ μi is the mean value of the random variable $X_i$, and the random variable described by the distribution is $\chi^2 = \sum_{i=1}^k X_i^2$. The parameter λ is the noncentrality parameter and is given by $\lambda = \sum_{i=1}^k \mu_i^2$.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ChiSquareDistr(long nu)
    Constructor.
    ChiSquareDistr(long nu, double lambda)
    Constructor for a non-central χ2 distribution.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determine if the domain minimum is in the domain.
    long
    Get the number of degrees of freedom.
    double
    Get the minimum value in the domain of the function.
    double
    Get the non-centrality parameter.
    boolean
    Determine if this object is a non-central χ2 distribution.
    boolean
    isSymmetric(double x)
    Determine if this distribution is symmetric about x.
    double
    P(double x)
    Get the probability that a value is no larger than the argument
    static double
    P(double chi2, long nu)
    Get the cumulative probability for a χ2 distribution.
    static double
    P(double chi2, long nu, double lambda)
    Get the cumulative probability distribution for a non-central χ2 distribution.
    double
    pd(double x)
    Get the probability density
    static double
    pd(double chi2, long nu)
    Get the probability density for a χ2 distribution.
    static double
    pd(double chi2, long nu, double lambda)
    Get the probability density for a non-central χ2 distribution.
    double
    Q(double x)
    Get the probability that a value is no smaller than the argument
    static double
    Q(double chi2, long nu)
    Get the complement of the cumulative probability for a χ2 distribution.
    static double
    Q(double chi2, long nu, double lambda)
    Get the complement of the cumulative probability distribution for a non-central χ2 distribution.

    Methods inherited from class org.bzdev.math.stats.ProbDistribution

    A, cdf, cdfc, domainMaxClosed, getDomainMax, inverseA, inverseP, inverseQ, isInDomain

    Methods inherited from class java.lang.Object

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

    • ChiSquareDistr

      public ChiSquareDistr(long nu)
      Constructor.
      Parameters:
      nu - the number of degrees of freedom
    • ChiSquareDistr

      public ChiSquareDistr(long nu, double lambda)
      Constructor for a non-central χ2 distribution. λ is defined as the sum of the squares of the means of the random variables whose squares are summed.
      Parameters:
      nu - the number of degrees of freedom
      lambda - the non-centrality parameter for the distribution
  • Method Details

    • getDegreesOfFreedom

      public long getDegreesOfFreedom()
      Get the number of degrees of freedom.
      Returns:
      the number of degrees of freedom
    • isNonCentral

      public boolean isNonCentral()
      Determine if this object is a non-central χ2 distribution.
      Returns:
      true if this object is a non-central χ2 distribution; false otherwise.
    • getLambda

      public double getLambda()
      Get the non-centrality parameter.
      Returns:
      the non-centrality parameter
      Throws:
      IllegalStateException - this object is not a non-central χ2 distribution
    • isSymmetric

      public boolean isSymmetric(double x)
      Description copied from class: ProbDistribution
      Determine if this distribution is symmetric about x. A distribution is symmetric if its probability density f satisfies f(x+y) = f(x-y) and that if x+y is in f's domain, so is x-y. Equivalently, it must satisfy Q(x+y) = P(x-y).
      Specified by:
      isSymmetric in class ProbDistribution
      Parameters:
      x - the point about which to test if this distribution is symmaetric
      Returns:
      true if it is symmetric; false otherwise.
    • pd

      public double pd(double x)
      Description copied from class: ProbDistribution
      Get the probability density
      Overrides:
      pd in class ProbDistribution
      Parameters:
      x - the value for which the density is to be computed
      Returns:
      the probability density
    • P

      public double P(double x)
      Description copied from class: ProbDistribution
      Get the probability that a value is no larger than the argument
      Specified by:
      P in class ProbDistribution
      Parameters:
      x - the argument
      Returns:
      the probability
    • Q

      public double Q(double x)
      Description copied from class: ProbDistribution
      Get the probability that a value is no smaller than the argument
      Overrides:
      Q in class ProbDistribution
      Parameters:
      x - the argument
      Returns:
      the probability
    • getDomainMin

      public double getDomainMin()
      Description copied from interface: RealValuedDomainOps
      Get the minimum value in the domain of the function.
      Specified by:
      getDomainMin in interface RealValuedDomainOps
      Overrides:
      getDomainMin in class ProbDistribution
      Returns:
      the minimum value
    • domainMinClosed

      public boolean domainMinClosed()
      Description copied from interface: RealValuedDomainOps
      Determine if the domain minimum is in the domain.
      Specified by:
      domainMinClosed in interface RealValuedDomainOps
      Overrides:
      domainMinClosed in class ProbDistribution
      Returns:
      true if the domain minimum is in the domain; false if it is the greatest lower bound for the domain
    • pd

      public static double pd(double chi2, long nu)
      Get the probability density for a χ2 distribution.
      Parameters:
      chi2 - the χ2 value
      nu - the number of degrees of freedom
      Returns:
      the χ2 probability density
    • P

      public static double P(double chi2, long nu)
      Get the cumulative probability for a χ2 distribution.
      Parameters:
      chi2 - the χ2 value
      nu - the number of degrees of freedom
      Returns:
      the corresponding value of the cumulative probability distribution
    • Q

      public static double Q(double chi2, long nu)
      Get the complement of the cumulative probability for a χ2 distribution.
      Parameters:
      chi2 - the χ2 value
      nu - the number of degrees of freedom
      Returns:
      a value mathematically equal to 1 - P(chi2, nu)
    • pd

      public static double pd(double chi2, long nu, double lambda)
      Get the probability density for a non-central χ2 distribution.
      Parameters:
      chi2 - the χ2 value
      nu - the number of degrees of freedom
      lambda - the non-centrality parameter for the distribution
      Returns:
      the value of the noncentral χ2 probability density for the specified parameters
    • P

      public static double P(double chi2, long nu, double lambda)
      Get the cumulative probability distribution for a non-central χ2 distribution.
      Parameters:
      chi2 - the χ2 value
      nu - the number of degrees of freedom
      lambda - the non-centrality parameter for the distribution
      Returns:
      the value of the cummulative distribution function for the specified parameters
    • Q

      public static double Q(double chi2, long nu, double lambda)
      Get the complement of the cumulative probability distribution for a non-central χ2 distribution.
      Parameters:
      chi2 - the χ2 value
      nu - the number of degrees of freedom
      lambda - the non-centrality parameter for the distribution
      Returns:
      the value of the complement of the cummulative distribution function for the specified parameters