StudentTDistribution

Represents Student's t-distribution, a continuous probability distribution defined on the entire real line.

Student's t-distribution arises when estimating the mean of a normally distributed population whose standard deviation is unknown and must be estimated from the data. It is the foundation of t-tests and confidence intervals for means. The distribution resembles the standard normal distribution but has heavier tails, which accounts for the additional uncertainty from estimating the standard deviation. As degreesOfFreedom increases, the t-distribution converges to the standard normal distribution.

The CDF is computed via the regularized incomplete beta function. Quantiles are found using Newton's method seeded with the corresponding standard normal quantile. Random samples are generated as the ratio of a standard normal draw to the square root of an independent chi-squared draw divided by its degrees of freedom.

Example:

val dist = StudentTDistribution(degreesOfFreedom = 10.0)
dist.mean // 0.0 (symmetric about zero)
dist.variance // 1.25 (greater than 1, reflecting heavier tails than normal)
dist.pdf(0.0) // 0.3891... (slightly less than normal's 0.3989)
dist.cdf(2.228) // 0.975 (approximately; critical value for 97.5th percentile)

// Critical value for a two-sided 95% confidence interval with 10 df
dist.quantile(0.975) // 2.228...

See also

Constructors

Link copied to clipboard
constructor(degreesOfFreedom: Double)

Properties

Link copied to clipboard

the number of degrees of freedom. Must be positive.

Link copied to clipboard
open override val entropy: Double

The differential entropy of this distribution.

Link copied to clipboard
open override val kurtosis: Double

The excess kurtosis of this distribution. Finite when df > 4, infinite when 2 < df <= 4, or NaN when df <= 2.

Link copied to clipboard
open override val mean: Double

The mean of this distribution, which is 0 when degrees of freedom exceeds 1, or NaN otherwise.

Link copied to clipboard
open override val skewness: Double

The skewness of this distribution, which is 0 when degrees of freedom exceeds 3, or NaN otherwise.

Link copied to clipboard
open override val variance: Double

The variance of this distribution. Finite when df > 2, infinite when 1 < df <= 2, or NaN when df <= 1.

Functions

Link copied to clipboard
open override fun cdf(x: Double): Double

Computes the cumulative distribution function at x.

Link copied to clipboard
open override fun logPdf(x: Double): Double

Computes the natural logarithm of the probability density at x.

Link copied to clipboard
open override fun pdf(x: Double): Double

Computes the probability density at x.

Link copied to clipboard
open override fun quantile(p: Double): Double

Computes the quantile (inverse CDF) for the given probability p.

Link copied to clipboard
open override fun sample(random: Random): Double

Draws a single random value from this Student's t-distribution.

Link copied to clipboard
open override fun sf(x: Double): Double

Computes the survival function (one minus the CDF) at x.