rcBinom {betafunctions}R Documentation

Random Number Generation under Lord's Two-Term Approximation to the Compound Binomial Distribution.

Description

Random Number Generation under Lord's Two-Term Approximation to the Compound Binomial Distribution.

Usage

rcBinom(n, N, k, p)

Arguments

n

Number of draws.

N

Number of trials.

k

Lord's k (see documentation for the Lords.k() function).

p

Probability of success for each trial.

Note

For larger values of k, the distribution can yield negative probabilities. This function handles such occurrences by adding the absolute value of the minimum probability to all observations if there are any negative probabilities and then normalize the distribution so that the total density is equal to 1.

Examples

# To draw a sample of 50 values from a Compound-Binomial distribution with
# number of trials = 100, a 50% probability of success for each trial, and
# Lord's k = 1:
set.seed(1234)
rcBinom(n = 50, N = 100, k = 1, p = .5)

# To draw values where the probabilities vary for each draw:
rcBinom(n = 50, N = 100, k = 1, p = runif(50))

[Package betafunctions version 1.9.0 Index]