Class StudentsTStat

java.lang.Object
org.bzdev.math.stats.Statistic
org.bzdev.math.stats.StudentsTStat
Direct Known Subclasses:
StudentsTStat.Mean1, StudentsTStat.Mean2, StudentsTStat.PairedDiff, StudentsTStat.Slope

public abstract class StudentsTStat extends Statistic
Base class for classes statistics for Student's t-test.

Each subclass provides a different statistic. A description of the statistic for each subclass is provided in the documentation for that subclass. For a test of the differences between two data sets with unequal variances, use WelchsTStat.

The methods this class implements allow one to determine the number of degrees of freedom and the probability distribution for this statistic. For a t-test, this distribution depends only on the number of degrees of freedom.

As described by the documentation for StudentsTDistr, the Student's t distribution is that of the random variable $T = Z \sqrt{\frac{\nu}{V}}$ where

  • Z is a Gaussian (or normal) random variable with an expected value of 0 and a mean of 1.
  • V is a random variable with a Χ2 distribution with ν degrees of freedom.
  • Z and V are independent random variables.
In a typical case, V will be a sample standard deviation divided by the square of the corresponding population standard deviation. Similarly, Z will be the sample mean of a random number for a sample size of n divided by $\frac{\sigma}{\sqrt{n}}$ where σ is the the random number's population standard deviation.
  • Constructor Details

    • StudentsTStat

      public StudentsTStat()
  • Method Details

    • setDegreesOfFreedom

      protected void setDegreesOfFreedom(int d)
      Set the number of degrees of freedom for this instance. This must be called by a subclass whenever the statistics are updated.
      Parameters:
      d - the degrees of freedom; 0 no data is available
    • getDegreesOfFreedom

      public int getDegreesOfFreedom()
      Get the degress of freedom.
      Returns:
      the degress of freedom
    • getDistribution

      public ProbDistribution getDistribution()
      Description copied from class: Statistic
      Get the probability distribution for this statistic. The distribution is the distribution for the statistic, not the the distribution for the data the statistic describes.
      Specified by:
      getDistribution in class Statistic
      Returns:
      the probability distribution
    • getDistribution

      public ProbDistribution getDistribution(double mu)
      Get a noncentral distribution for this statistic. The definition of μ provided by StudentsTDistr, has to be applied to specific cases.
      Overrides:
      getDistribution in class Statistic
      Parameters:
      mu - the noncentrality parameter
      Returns:
      the probability distribution
      Throws:
      IllegalArgumentException - the argument is not allowed for this statistic
      IllegalStateException - the state of this statistic does not allow this function to return a meaningful value (e.g., because enough data has not be provided)
    • getNCParameter

      public abstract double getNCParameter(double diff)
      Get the noncentrality parameter given a difference in mean values. A Student's t-test can typically be written as $$ T = \frac{\mbox{x̅} - \mu_0}{ \frac{\sigma}{\sqrt{n}} \sqrt{\frac{S}{\sigma^2\nu}} }$$ where ν is the number of degrees of freedom, σ is the population standard deviation of a random variable for which x is the sample mean of X, μ0 is the population mean of X, n is the sample size, and S is a sum of squares. Note that $\sqrt{\frac{S}{\sigma^2\nu}}$ will be the sample standard deviation for a suitable choice of ν.

      If we set θ = μ1 - μ0, we can express T as $$T = \frac{\mbox{x̅} - \mu_0 +\theta - \theta }{ \frac{\sigma}{\sqrt{n}} \frac{S/\sigma^2}{\sqrt{\nu}} }$$ or $$T = \frac{\mbox{x̅} - \mu_1 + \theta }{ \frac{\sigma}{\sqrt{n}} \frac{S/\sigma^2}{\sqrt{\nu}} } \ .$$ If we set $Z = \frac{\mbox{x̅} - \mu_1}{\sigma/\sqrt{n}}$ and $\mu = \frac{\theta}{\sigma/\sqrt{n}}$, then T can be written as $\frac{Z+\mu}{\sqrt{V/\nu}}$. If the actual mean is μ1, then Z has a normal distribution with a mean of zero and a variance of 1. Meanwhile V has a χ2 distribution with ν degrees of freedom, and Z and V are independent. Consequently, the random variable $\frac{Z + \mu}{\sqrt{V/\nu}}$ has a noncentral t distribution characterized by the number of degrees of freedom ν and the noncentrality parameter μ.

      For citations for specific cases, please see

      The notation in this documentation will differ slightly due to the use of a lower-case x instead of an upper-case X as part of a work-around for a mathjax bug involving the LaTeX 'overline' command.
      Overrides:
      getNCParameter in class Statistic
      Parameters:
      diff - the difference of the H1 mean value and the H0 mean value.
      Returns:
      the noncentrality parameter