Stable lifecycle

dist_f(df1, df2, ncp = NULL)

Arguments

df1

degrees of freedom. Inf is allowed.

df2

degrees of freedom. Inf is allowed.

ncp

non-centrality parameter. If omitted the central F is assumed.

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 Gamma random variable with parameters shape = \(\alpha\) and rate = \(\beta\).

Support: \(x \in (0, \infty)\)

Mean: \(\frac{\alpha}{\beta}\)

Variance: \(\frac{\alpha}{\beta^2}\)

Probability density function (p.m.f):

$$ f(x) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x} $$

Cumulative distribution function (c.d.f):

$$ f(x) = \frac{\Gamma(\alpha, \beta x)}{\Gamma{\alpha}} $$

Moment generating function (m.g.f):

$$ E(e^{tX}) = \Big(\frac{\beta}{ \beta - t}\Big)^{\alpha}, \thinspace t < \beta $$

See also

stats::FDist

Examples

dist <- dist_f(df1 = c(1,2,5,10,100), df2 = c(1,1,2,1,100)) dist
#> <distribution[5]> #> [1] F(1, 1) F(2, 1) F(5, 2) F(10, 1) F(100, 100)
mean(dist)
#> [1] NA NA NA NA 1.020408
variance(dist)
#> [1] NA NA NA NA 0.04295085
skewness(dist)
#> [1] NA NA NA NA 0.6243619
kurtosis(dist)
#> [1] NA NA NA NA 0.7278883
generate(dist, 10)
#> [[1]] #> [1] 218.95735597 1.42122852 0.01139180 49.34664679 0.28216794 #> [6] 0.46467548 0.02499175 0.66197859 0.01670880 0.68518123 #> #> [[2]] #> [1] 0.86941149 8.51580884 0.01076928 0.53595194 2.13224877 1.63389072 #> [7] 0.36934871 2.66770146 46.99455676 0.82291496 #> #> [[3]] #> [1] 1.9199966 4.5747585 0.5516530 1.3009477 0.4731514 1.1264750 #> [7] 61.8950673 0.5723505 3.0749360 2.7524941 #> #> [[4]] #> [1] 0.2585130 259.3719203 34.9102761 1.1025752 0.6952306 37.6286702 #> [7] 1.2637445 0.6966682 5.2916096 3.2341293 #> #> [[5]] #> [1] 0.8893561 0.9952326 0.6702151 0.7911508 0.9858228 1.1232301 1.4441917 #> [8] 1.4935505 1.4810405 1.4016343 #>
density(dist, 2)
#> [1] 0.075026360 0.089442719 0.132070447 0.105192421 0.002755106
density(dist, 2, log = TRUE)
#> [1] -2.589916 -2.414157 -2.024420 -2.251964 -5.894300
cdf(dist, 4)
#> [1] 0.7048328 0.6666667 0.7879856 0.6278936 1.0000000
quantile(dist, 0.7)
#> [1] 3.851840 5.055556 2.608427 6.357893 1.110896