Skip to contents

Density, distribution function, quantile function and random generation for the Bell distribution with parameter theta.

Usage

dbell(x, theta, log = FALSE)

pbell(x, theta)

rbell(n, theta, max_z = 100L)

qbell(p, theta, max_z = 100L)

Arguments

x

vector of nonnegative integers (for dbell and pbell).

theta

scalar nonnegative Bell parameter.

log

logical; if TRUE, probabilities p are given as log(p).

n

number of observations to generate (for rbell).

max_z

maximum support value used for approximation in rbell and qbell.

p

numeric vector of probabilities between 0 and 1 inclusive (for qbell).

Value

For dbell, a numeric vector of probabilities. For pbell, a numeric vector of cumulative probabilities. For qbell, an integer vector of quantiles. For rbell, an integer vector of random values.

Details

Let \(B_x\) denote the xth Bell number. The Bell distribution has probability mass function $$ P(X = x) = \theta^x \exp(-\exp(\theta) + 1) \frac{B_x}{x!}, $$ for nonnegative integers \(x\) and \(\theta \ge 0\).

For \(\theta > 0\), the Bell mean is \(E[X] = \theta e^\theta\). At \(\theta = 0\), the distribution is degenerate at 0.

The functions follow the standard naming used in base R: dbell for the density, pbell for the distribution function, qbell for the quantile function and rbell for random generation.

Examples

dbell(0:5, theta = 1)
#> [1] 0.17937408 0.17937408 0.17937408 0.14947840 0.11210880 0.07772877
pbell(0:5, theta = 1)
#> [1] 0.1793741 0.3587482 0.5381222 0.6876006 0.7997094 0.8774382
qbell(c(0.25, 0.5, 0.9), theta = 1)
#> [1] 1 2 6
set.seed(1)
rbell(10, theta = 1)
#>  [1] 3 1 0 5 3 0 2 7 5 1