Binomial distribution with size \(n\) and probability of success \(p\).

expValBinom(size, prob)

varBinom(size, prob)

expValTruncBinom(d, size, prob, less.than.d = TRUE)

VatRBinom(kap, size, prob)

TVatRBinom(kap, size, prob)

pgfBinom(t, size, prob)

mgfBinom(t, size, prob)

Arguments

size

Number of trials (0 or more).

prob

Probability of success in each trial.

d

cut-off value.

less.than.d

logical; if TRUE (default) truncated mean for values <= d, otherwise, for values > d.

kap

probability.

t

t.

Value

Function :

  • mgfBinom gives the moment generating function (MGF).

  • pgfBinom gives the probability generating function (PGF).

  • expValBinom gives the expected value.

  • varBinom gives the variance.

  • expValTruncBinom gives the truncated mean.

  • TVatRBinom gives the Tail Value-at-Risk.

  • VatRBinom gives the Value-at-Risk.

Invalid parameter values will return an error detailing which parameter is problematic.

Details

The binomial distribution with probability of success \(p\) for \(n\) trials has probability mass function : $$Pr(X = k) = \left(\frac{n}{k}\right) p^n (1 - p)^{n - k}$$ for \(k = 0, 1, 2, \dots, n\), \(p \in [0, 1]\), and \(n > 0\)

Note

Function VatRBinom is a wrapper of the qbinom function from the stats package.

Examples

expValBinom(size = 3, prob = 0.5)
#> [1] 1.5

varBinom(size = 3, prob = 0.5)
#> [1] 0.75


expValTruncBinom(d = 2, size = 3, prob = 0.5)
#> [1] 1.125
expValTruncBinom(d = 0, size = 3, prob = 0.5, less.than.d = FALSE)
#> [1] 1.5


VatRBinom(kap = 0.8, size = 5, prob = 0.2)
#> [1] 2

TVatRBinom(kap = 0.8, size = 5, prob = 0.2)
#> [1] 2.3248


pgfBinom(t = 1, size = 3, prob = 0.5)
#> [1] 1

mgfBinom(t = 1, size = 3, prob = 0.5)
#> [1] 6.425944