binornd
Random numbers from binomial distribution
Description
generates random numbers from the binomial distribution specified by the number of trials
r
= binornd(n
,p
)n
and the probability of success for each trial
p
.
n
and p
can be vectors, matrices, or
multidimensional arrays of the same size. Alternatively, one or more arguments can be
scalars. The binornd
function expands scalar inputs to constant arrays
with the same dimensions as the other inputs. The function returns a vector, matrix, or
multidimensional array r
of the same size as n
and
p
.
generates an array of random numbers from the binomial distribution with the scalar
parameters r
= binornd(n
,p
,sz1,...,szN
)n
and p
, where
sz1,...,szN
indicates the size of each dimension.
Examples
Input Arguments
Output Arguments
Alternative Functionality
binornd
is a function specific to binomial distribution. Statistics and Machine Learning Toolbox™ also offers the generic functionrandom
, which supports various probability distributions. To userandom
, specify the probability distribution name and its parameters. Alternatively, create aBinomialDistribution
probability distribution object and pass the object as an input argument. Note that the distribution-specific functionbinornd
is faster than the generic functionrandom
.To generate random numbers interactively, use
randtool
, a user interface for random number generation.
Extended Capabilities
Version History
Introduced before R2006a