[Stable]

dist_f(df1, df2, ncp = NULL)

Arguments

df1, 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]   0.4720441   0.4743386   0.3134471  57.1365590   0.3697037 719.9992235
#>  [7]   5.0063191  61.4585702  44.1580144   0.1464838
#> 
#> [[2]]
#>  [1]  7.84614676 73.11269824  0.93533527  1.93899119  6.04336713  0.13892610
#>  [7] 26.09388299  1.52559361  0.02756035  1.56496578
#> 
#> [[3]]
#>  [1] 0.7020620 0.1981885 0.7426476 5.7114292 1.5658225 1.5903515 1.1549140
#>  [8] 0.7291385 0.1854272 0.7424301
#> 
#> [[4]]
#>  [1]   9.5110842   0.8700710   0.6470577   0.4298532   3.1571969 228.2107278
#>  [7]   1.6611376   0.7313240   6.7604009   1.4627553
#> 
#> [[5]]
#>  [1] 1.2019521 0.8593970 1.0294035 0.7412580 0.8228456 0.8554432 1.0361816
#>  [8] 0.7624432 0.8513167 0.9087091
#> 

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