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.

StudentsT(df)

df | Degrees of freedom. Can be any positive number. Often called \(\nu\) in textbooks. |
---|

A `StudentsT`

object.

We recommend reading this documentation on https://alexpghayes.github.io/distributions3, where the math will render with additional detail and much greater clarity.

In the following, let \(X\) be a 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}} $$

**Cumulative distribution function (c.d.f)**:

Nasty, omitted.

**Moment generating function (m.g.f)**:

Undefined.

Other continuous distributions: `Beta`

,
`Cauchy`

, `ChiSquare`

,
`Exponential`

, `FisherF`

,
`Gamma`

, `LogNormal`

,
`Logistic`

, `Normal`

,
`Tukey`

, `Uniform`

,
`Weibull`

#> Student's T distribution (df = 3)#> [1] 1.4854556 -0.3809239 -1.8376741 0.1105147 0.3005249 0.1558420 #> [7] -1.5135073 -0.6088114 -2.4080689 -1.1878884#> [1] 0.06750966#> [1] -2.695485#> [1] 0.9859958#> [1] 0.5843897### example: calculating p-values for two-sided T-test # here the null hypothesis is H_0: mu = 3 # data to test x <- c(3, 7, 11, 0, 7, 0, 4, 5, 6, 2) nx <- length(x) # calculate the T-statistic t_stat <- (mean(x) - 3) / (sd(x) / sqrt(nx)) t_stat#> [1] 1.378916# null distribution of statistic depends on sample size! T <- StudentsT(df = nx - 1) # calculate the two-sided p-value 1 - cdf(T, abs(t_stat)) + cdf(T, -abs(t_stat))#> [1] 0.2012211#> [1] 0.2012211#> [1] 0.1006105#> [1] 0.8993895### example: calculating a 88 percent T CI for a mean # lower-bound mean(x) - quantile(T, 1 - 0.12 / 2) * sd(x) / sqrt(nx)#> [1] 2.631598#> [1] 6.368402#> [1] 2.631598 6.368402#> [1] 2.631598#> [1] 6.368402