java.lang.Object
org.bzdev.math.stats.ProbDistribution
org.bzdev.math.stats.StudentsTDistr
- All Implemented Interfaces:
RealValuedDomainOps
Class providing methods for Student's t-distribution.
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.
This distribution is the distribution of a random variable $T = Z \sqrt{\frac{\nu}{V}}$ where
- Z is a Gaussian (or normal) random variable with an expected (or mean) value of 0 and a stadard deviation of 1.
- V is a random variable with a Χ2 distribution with ν degrees of freedom.
- Z and V are independent random variables.
This class also handles the noncentral t distribution, where the random variable $T = (Z + \mu)\sqrt{\frac{\nu}{V}}$, where μ is the noncentrality parameter and Z, V, and ν are defined above.
-
Constructor Summary
ConstructorsConstructorDescriptionStudentsTDistr
(int nu) Constructor.StudentsTDistr
(int nu, double mu) Constructor for a noncentral t distribution. -
Method Summary
Modifier and TypeMethodDescriptiondouble
A
(double x) Get the probability that a value is within the range [-x, x].static double
A
(double t, int nu) Compute the probability that a value deviates from 0 by no more than a specified amount.double
Get the noncentrality 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 argumentstatic double
P
(double t, int nu) Get the cumulative probability for a Student's t-distribution.static double
P
(double t, int nu, double mu) Compute the value of the cumulative distribution function for a noncentral t distribution.double
pd
(double x) Get the probability densitystatic double
pd
(double t, int nu) Get the probability density for a Student's t-distribution.static double
pd
(double t, int nu, double mu) Compute the probability density for noncentral t distribution.double
Q
(double x) Get the probability that a value is no smaller than the argumentstatic double
Q
(double t, int nu) Get the complement of the cumulative probability for a Student's t-distribution.static double
Q
(double t, int nu, double mu) Compute the value of the complement of the cumulative distribution function for a noncentral t distribution.Methods inherited from class org.bzdev.math.stats.ProbDistribution
cdf, cdfc, domainMaxClosed, domainMinClosed, getDomainMax, getDomainMin, inverseA, inverseP, inverseQ, isInDomain
-
Constructor Details
-
StudentsTDistr
public StudentsTDistr(int nu) Constructor.- Parameters:
nu
- the number of degrees of freedom ν
-
StudentsTDistr
public StudentsTDistr(int nu, double mu) Constructor for a noncentral t distribution. The distribution not be considered to be noncentral if the parameter μ is precisely zero.- Parameters:
nu
- the number of degrees of freedom νmu
- the noncentrality parameter μ
-
-
Method Details
-
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.
-
getNCParameter
public double getNCParameter()Get the noncentrality parameter.- Returns:
- the noncentrality 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 classProbDistribution
- 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 classProbDistribution
- 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 classProbDistribution
- 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 classProbDistribution
- Parameters:
x
- the argument- Returns:
- the probability
-
A
public double A(double x) Description copied from class:ProbDistribution
Get the probability that a value is within the range [-x, x]. This method is meaningful for distributions that are symmetric about 0. When this is not the case, an UnsupportedOperationException should be thrown.- Overrides:
A
in classProbDistribution
- Parameters:
x
- the argument- Returns:
- the probability that a value is in the range [-x, x]
-
pd
public static double pd(double t, int nu) Get the probability density for a Student's t-distribution.- Parameters:
t
- the value at which to compute the probability densitynu
- the number of degrees of freedom- Returns:
- the Χ2 probability density
-
P
public static double P(double t, int nu) Get the cumulative probability for a Student's t-distribution.- Parameters:
t
- the value at which to compute the cumulative probabilitynu
- the number of degrees of freedom- Returns:
- the probability that the a value is in the range (-∞,t]
-
Q
public static double Q(double t, int nu) Get the complement of the cumulative probability for a Student's t-distribution. The value returned is given by Q(t,ν) = 1 - P(t, ν) where ν is the number of degrees of freedom, t∈(-∞∞), and P is the cumulative probability distribution.- Parameters:
t
- the Student's T valuenu
- the number of degrees of freedom- Returns:
- the corresponding value of the cumulative probability distribution
-
A
public static double A(double t, int nu) Compute the probability that a value deviates from 0 by no more than a specified amount. The probability is equal to the integral of the probability density from -t to t for ν degrees of freedom with t∈[0,;∞), and consequently A(t,ν) = P(t,ν)-P(-t,ν). The value is computed using a finite series given by Abramowitz & Stegun, Equations 26.7.3 and 26.7.4 (there is a different series for even and odd values of ν.) For this implementation, A(-t,ν) = -A(tν) although generally one would use only non-negative values of t.- Parameters:
t
- the Student's T valuenu
- the number of degrees of freedom- Returns:
- the probability that a value is in the range [-t,t]
-
pd
public static double pd(double t, int nu, double mu) Compute the probability density for noncentral t distribution. The distribution is that of the random variable T = (Z + μ)/sqrt(V/ν), where Z is random variable with a normal distribution, μ is a constant, and V is a Χ2-distributed random variable with ν degrees of freedom.- Parameters:
t
- the value at which the probability density is computednu
- the number of degrees of freedom νmu
- the noncentrality parameter μ- Returns:
- the probability density for the given arguments
-
P
public static double P(double t, int nu, double mu) Compute the value of the cumulative distribution function for a noncentral t distribution. The distribution is that of the random variable T = (Z + μ)/sqrt(V/ν), where Z is random variable with a normal distribution, μ is a constant, and V is a Χ2-distributed random variable with ν degrees of freedom.- Parameters:
t
- the value at which the probability density is computednu
- the number of degrees of freedom νmu
- the noncentrality parameter μ- Returns:
- the value of the cumulative distribution function
-
Q
public static double Q(double t, int nu, double mu) Compute the value of the complement of the cumulative distribution function for a noncentral t distribution. The distribution is that of the random variable T = (Z + μ)/sqrt(V/ν), where Z is random variable with a normal distribution, μ is a constant, and V is a Χ2-distributed random variable with ν degrees of freedom.- Parameters:
t
- the value at which the probability density is computednu
- the number of degrees of freedom νmu
- the noncentrality parameter μ- Returns:
- the complement of the cumulative distribution evaluated at the given arguments
-