`R/dist_student_t.R`

`dist_student_t.Rd`

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)`

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

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}} $$

```
dist <- dist_student_t(df = c(1,2,5), mu = c(0,1,2), sigma = c(1,2,3))
dist
#> <distribution[3]>
#> [1] t(1, 0, 1) t(2, 1, 2) t(5, 2, 3)
mean(dist)
#> [1] NA 1 2
variance(dist)
#> [1] NA Inf 15
generate(dist, 10)
#> [[1]]
#> [1] -0.1513792 -1.0331547 0.1735834 0.4428521 -0.5343736 -3.5785217
#> [7] 0.3979713 3.7598121 -0.5545936 1.6795692
#>
#> [[2]]
#> [1] -0.04629611 -5.68847653 2.63249610 -1.34682410 1.82364884 0.14587925
#> [7] 0.91150380 6.58696982 0.52254673 -1.00280719
#>
#> [[3]]
#> [1] 2.7607236 0.4045694 2.0192026 -1.2172105 -3.9120998 4.9832395
#> [7] 5.2664184 4.5169634 4.7375040 1.0691997
#>
density(dist, 2)
#> [1] 0.06366198 0.14814815 0.12653556
density(dist, 2, log = TRUE)
#> [1] -2.754168 -1.909543 -2.067232
cdf(dist, 4)
#> [1] 0.9220209 0.8638034 0.7327454
quantile(dist, 0.7)
#> [1] 0.7265425 2.2344268 3.6782889
```