dist_chisq(df, ncp = 0)

## Arguments

df degrees of freedom (non-negative, but can be non-integer). non-centrality parameter (non-negative).

## Details

Chi-square distributions show up often in frequentist settings as the sampling distribution of test statistics, especially in maximum likelihood estimation settings.

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

In the following, let $$X$$ be a $$\chi^2$$ random variable with df = $$k$$.

Support: $$R^+$$, the set of positive real numbers

Mean: $$k$$

Variance: $$2k$$

Probability density function (p.d.f):

$$f(x) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-(x - \mu)^2 / 2 \sigma^2}$$

Cumulative distribution function (c.d.f):

The cumulative distribution function has the form

$$F(t) = \int_{-\infty}^t \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-(x - \mu)^2 / 2 \sigma^2} dx$$

but this integral does not have a closed form solution and must be approximated numerically. The c.d.f. of a standard normal is sometimes called the "error function". The notation $$\Phi(t)$$ also stands for the c.d.f. of a standard normal evaluated at $$t$$. Z-tables list the value of $$\Phi(t)$$ for various $$t$$.

Moment generating function (m.g.f):

$$E(e^{tX}) = e^{\mu t + \sigma^2 t^2 / 2}$$

## Examples

dist <- dist_chisq(df = c(1,2,3,4,6,9))

dist
#> <distribution>
#>  \u1d6a²(1) \u1d6a²(2) \u1d6a²(3) \u1d6a²(4) \u1d6a²(6) \u1d6a²(9)mean(dist)
#>  1 2 3 4 6 9variance(dist)
#>   2  4  6  8 12 18skewness(dist)
#>  2.828427 2.000000 1.632993 1.414214 1.154701 0.942809kurtosis(dist)
#>  12.000000  6.000000  4.000000  3.000000  2.000000  1.333333
generate(dist, 10)
#> []
#>   0.72601085 0.93071502 0.02579683 0.08327627 0.42007532 1.86026126
#>   0.77809157 0.11670245 2.61405677 0.02478708
#>
#> []
#>   0.6910968 4.3422720 1.6989898 1.1801349 5.1658135 5.6831134 0.6983211
#>   1.4066345 4.9075193 0.4674858
#>
#> []
#>    3.169329  1.799478  2.351222  2.506705  2.500567  1.515333  1.164510
#>    4.038398 15.613134  2.493755
#>
#> []
#>   6.1652771 6.4518952 6.3843386 2.1063540 8.1999058 6.5853996 8.9435799
#>   2.3703962 2.2069658 0.9125746
#>
#> []
#>    4.982996 16.885079  2.017798  4.772882  1.789387  5.017964  3.160282
#>    6.399912  1.462012  7.077559
#>
#> []
#>    8.236767  3.672691  8.504930  4.504704  8.915198  5.628488 11.086178
#>    3.053023  6.015485 11.267140
#>
density(dist, 2)
#>  0.10377687 0.18393972 0.20755375 0.18393972 0.09196986 0.01581362density(dist, 2, log = TRUE)
#>  -2.265512 -1.693147 -1.572365 -1.693147 -2.386294 -4.146884
cdf(dist, 4)
#>  0.95449974 0.86466472 0.73853587 0.59399415 0.32332358 0.08858747
quantile(dist, 0.7)
#>   1.074194  2.407946  3.664871  4.878433  7.231135 10.656372