This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Binomial random numbers


R = binornd(N,P)
R = binornd(N,P,m,n,...)
R = binornd(N,P,[m,n,...])


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,m,n,...) or R = binornd(N,P,[m,n,...]) generates an m-by-n-by-... array containing random numbers from the binomial distribution with parameters N and P. N and P can each be scalars or arrays of the same size as R.


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


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

Extended Capabilities

Introduced before R2006a

Was this topic helpful?