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...