rbinomial: Simulates from a binomial distribution

View source: R/stochastic_simulation.R

rbinomialR Documentation

Simulates from a binomial distribution

Description

Simulates one value from a binomial distribution with parameters size (the number of independent Bernoulli trials) and prob (the probability of success on any given trial).

Usage

rbinomial(size, prob)

Arguments

size

An integer scalar. The number of trials.

prob

A numeric scalar. The probability of success on each trial.

Details

Take a look at this function's code in the Stochastic Simulation vignette and see whether you can understand how it works.

Value

A numeric scalar: the simulated number of successes in size trials.

See Also

link{rbinom} for the official R function for simulating from a binomial distribution.

Examples

# Simulate one value from a binomial(6, 0.2) distribution.
rbinomial(size = 6, prob = 0.2)

paulnorthrop/stat0002 documentation built on Oct. 10, 2024, 1:27 p.m.