Learn R Programming

Runuran (version 0.40)

udbinom: UNU.RAN object for Binomial distribution

Description

Create UNU.RAN object for a Binomial distribution with parameters size and prob.

[Distribution] -- Binomial.

Usage

udbinom(size, prob, lb=0, ub=size)

Value

An object of class "unuran.discr".

Arguments

size

number of trials (one or more).

prob

probability of success on each trial.

lb

lower bound of (truncated) distribution.

ub

upper bound of (truncated) distribution.

Author

Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.

Details

The Binomial distribution with size \(= n\) and prob \(= p\) has probability mass function $$p(x) = {n \choose x} {p}^{x} {(1-p)}^{n-x} $$ for \(x = 0, \ldots, n\).

The domain of the distribution can be truncated to the interval (lb,ub).

References

N.L. Johnson, S. Kotz, and A.W. Kemp (1992): Univariate Discrete Distributions. 2nd edition, John Wiley & Sons, Inc., New York. Chap. 3, p. 105.

See Also

unuran.discr.

Examples

Run this code
## Create distribution object for Binomial distribution
dist <- udbinom(size=100, prob=0.33)
## Generate generator object; use method DGT (inversion)
gen <- dgtd.new(dist)
## Draw a sample of size 100
x <- ur(gen,100)

Run the code above in your browser using DataLab