FreeMat: RANDBIN Generate Binomial Random Variables

FreeMat

- Main Page
- Related Pages

RANDBIN Generate Binomial Random Variables

Section: Random Number Generation

# Usage

Generates random variables with a binomial distribution. The general syntax for its use is

       y = randbin(N,p)

where `N` is a vector representing the number of Bernoulli trials, and `p` is the success probability associated with each trial.

# Internals

A Binomial random variable describes the number of successful outcomes from `N` Bernoulli trials, with the probability of success in each trial being `p`. The probability distribution is

# Example

Here we generate `10` 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 =
      6  7  6  7 13  7  7 10 13 15

    --> sum(rand(100,10)<0.1)

    ans =
     11  9  8  9 15 16 11 17  4  7