Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

binornd - Binomial random numbers

Syntax

R = binornd(N,P)
R = binornd(N,P,v)
R = binornd(N,p,m,n)

Description

R = binornd(N,P) generates random numbers from the binomial distribution with parameters specified by the number of trials, N, and probability of success for each trial, P. N and P can be vectors, matrices, or multidimensional arrays that have the same size, which is also the size of R. A scalar input for N or P is expanded to a constant array with the same dimensions as the other input.

R = binornd(N,P,v) generates an array R of size v containing random numbers from the binomial distribution with parameters N and P, where v is a row vector. If v is a 1-by-2 vector, R is a matrix with v(1) rows and v(2) columns. If v is 1-by-n, R is an n-dimensional array.

R = binornd(N,p,m,n) generates an m-by-n matrix containing random numbers from the binomial distribution with parameters N and P.

Algorithm

The binornd function uses the direct method using the definition of the binomial distribution as a sum of Bernoulli random variables.

Examples

n = 10:10:60;

r1 = binornd(n,1./n)
r1 =
   2   1   0   1   1   2

r2 = binornd(n,1./n,[1 6])
r2 =
   0   1   2   1   3   1

r3 = binornd(n,1./n,1,6)
r3 =
   0   1   1   1   0   3

See Also

binocdf | binofit | binoinv | binopdf | binostat | random

How To

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS