 The Student's T distribution is closely related to the Normal() distribution, but has heavier tails. As $$\nu$$ increases to $$\infty$$, the Student's T converges to a Normal. The T distribution appears repeatedly throughout classic frequentist hypothesis testing when comparing group means.

dist_student_t(df, mu = 0, sigma = 1, ncp = NULL)

## Arguments

df

degrees of freedom ($$> 0$$, maybe non-integer). df = Inf is allowed.

mu

The location parameter of the distribution. If ncp == 0 (or NULL), this is the median.

sigma

The scale parameter of the distribution.

ncp

non-centrality parameter $$\delta$$; currently except for rt(), only for abs(ncp) <= 37.62. If omitted, use the central t distribution.

## Details

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

In the following, let $$X$$ be a central Students T random variable with df = $$\nu$$.

Support: $$R$$, the set of all real numbers

Mean: Undefined unless $$\nu \ge 2$$, in which case the mean is zero.

Variance:

$$\frac{\nu}{\nu - 2}$$

Undefined if $$\nu < 1$$, infinite when $$1 < \nu \le 2$$.

Probability density function (p.d.f):

$$f(x) = \frac{\Gamma(\frac{\nu + 1}{2})}{\sqrt{\nu \pi} \Gamma(\frac{\nu}{2})} (1 + \frac{x^2}{\nu} )^{- \frac{\nu + 1}{2}}$$

## Examples

dist <- dist_student_t(df = c(1,2,5), mu = c(0,1,2), sigma = c(1,2,3))

dist
#> <distribution>
#>  t(1, 0, 1) t(2, 1, 2) t(5, 2, 3)
mean(dist)
#>  NA  1  2
variance(dist)
#>   NA Inf  15

generate(dist, 10)
#> []
#>    -0.2376976   2.7028375  -0.7398979  -0.2558735 -15.9741700   2.9718859
#>    -0.8464584   6.7327917  -0.3692740  -0.7361845
#>
#> []
#>    0.6798662 -1.0222071 -0.3087564 -1.1798892 -0.5993500 -2.1881818
#>    8.6504759  1.9491613 -0.4840127 -0.4987401
#>
#> []
#>   -5.9496078  9.9714002  4.9100926 -2.6910350 -2.9959744  0.9310802
#>    4.2089343  3.8659415  1.0144862 -0.9375793
#>

density(dist, 2)
#>  0.06366198 0.14814815 0.12653556
density(dist, 2, log = TRUE)
#>  -2.754168 -1.909543 -2.067232

cdf(dist, 4)
#>  0.9220209 0.8638034 0.7327454

quantile(dist, 0.7)
#>  0.7265425 2.2344268 3.6782889