NBinom: Negative Binomial Distribution

Description Usage Arguments Details Value Examples

Description

Negative binomial distribution with parameters r (number of successful trials) and p (probability of success).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
expValNBinom(
  size,
  prob = (1/(1 + beta)),
  beta = ((1 - prob)/prob),
  nb_tries = FALSE
)

varNBinom(
  size,
  prob = (1/(1 + beta)),
  beta = ((1 - prob)/prob),
  nb_tries = FALSE
)

mgfNBinom(
  t,
  size,
  prob = (1/(1 + beta)),
  beta = ((1 - prob)/prob),
  nb_tries = FALSE
)

pgfNBinom(
  t,
  size,
  prob = (1/(1 + beta)),
  beta = ((1 - prob)/prob),
  nb_tries = FALSE
)

Arguments

size

Number of successful trials.

prob

Probability of success in each trial.

beta

Alternative parameterization of the negative binomial distribution where beta = (1 - p) / p.

nb_tries

logical; if FALSE (default) number of trials until the rth success, otherwise, number of failures until the rth success.

t

t.

Details

When k is the number of failures until the rth success, with a probability p of a success, the negative binomial has density:

Pr(M = k) = choose(r + k - 1, k) p^r (1 - p)^k

for k = 0, 1, 2, ...

When k is the number of trials until the rth success, with a probability p of a success, the negative binomial has density:

Pr(M = k) = choose(k - 1, r - 1) p^r (1 - p)^(k - r)

for k = r, r + 1, r + 2, ...

The alternative parameterization of the negative binomial with parameter beta, and k being the number of trials, has density:

Pr(M = k) = (r + k - 1)!/((r - 1)! k!) (1/(1 + beta))^r (beta/(1 + beta))^(k - r)

for k = 0, 1, 2, ...

Value

Function :

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Where k is the number of trials for a rth success
expValNBinom(size = 2, prob = .4)

# Where k is the number of failures before a rth success
expValNBinom(size = 2, prob = .4, nb_tries = TRUE)

# With alternative parameterization where k is the number of trials
expValNBinom(size = 2, beta = 1.5)


# Where k is the number of trials for a rth success
varNBinom(size = 2, prob = .4)

# Where k is the number of failures before a rth success
varNBinom(size = 2, prob = .4, nb_tries = TRUE)

# With alternative parameterization where k is the number of trials
varNBinom(size = 2, beta = 1.5)

mgfNBinom(t = 1, size = 4, prob = 0.5)

pgfNBinom(t = 5, size = 3, prob = 0.3)

Distributacalcul documentation built on Sept. 13, 2020, 5:19 p.m.