RANDBIN Generate Binomial Random Variables
Section: Random Number Generation
Usage
Generates random variables with a binomial distribution. The general syntax for its use isy = randbin(N,p)
where N
is a vector representing the number of Bernoulli
trials, and p
is the success probability associated with each
trial.
Function Internals
A Binomial random variable describes the number of successful outcomes fromN
Bernoulli trials, with the probability of
success in each trial being p
. The probability distribution
is
Example
Here we generate10
binomial random variables, corresponding
to N=100
trials, each with probability p=0.1
, using
both randbin
and then again using rand
(to simulate the trials):
--> randbin(100,.1*ones(1,10)) ans = 13 6 8 9 11 9 6 9 7 10 --> sum(rand(100,10)<0.1) ans = 8 12 10 7 12 4 11 8 9 6