Skip to contents

Functions to compute the probability density function, cumulative distribution function, and quantile function for the Binomial distribution.

Usage

binomial_pdf(k, n, prob)

binomial_lpdf(k, n, prob)

binomial_cdf(k, n, prob)

binomial_lcdf(k, n, prob)

binomial_quantile(p, n, prob)

Arguments

k

number of successes (0 <= k <= n)

n

number of trials (n >= 0)

prob

probability of success on each trial (0 <= prob <= 1)

p

probability (0 <= p <= 1)

Value

A single numeric value with the computed probability density, log-probability density, cumulative distribution, log-cumulative distribution, or quantile depending on the function called.

See also

Boost Documentation for more details on the mathematical background.

Examples

# Binomial dist ribution with n = 10, prob = 0.5
binomial_pdf(3, 10, 0.5)
#> [1] 0.1171875
binomial_lpdf(3, 10, 0.5)
#> [1] -2.14398
binomial_cdf(3, 10, 0.5)
#> [1] 0.171875
binomial_lcdf(3, 10, 0.5)
#> [1] -1.760988
binomial_quantile(0.5, 10, 0.5)
#> [1] 5