random
Random numbers
Syntax
Y = random(pd)
Y = random(pd,m,n,...)
Y = random(pd,[m,n,...])
Y = random(name,A)
Y = random(name,A,B)
Y = random(name,A,B,C)
Y = random(name,A,B,C,D)
Y = random(name,A,m,n,...)
Y = random(name,A,[m,n,...])
Y = random(name,A,B,m,n,...)
Y = random(name,A,B,[m,n,...])
Y = random(name,A,B,C,m,n,...)
Y = random(name,A,B,C,[m,n,...])
Y = random(name,A,B,C,D,m,n,...)
Y = random(name,A,B,C,D,[m,n,...])
Description
Y = random(pd) returns a random number Y from the distribution specified by the probability distribution object pd.
You can create a probability distribution object with specified parameter values using makedist, or fit a probability
distribution object to sample data using fitdist.
Y = random(name,A) where name is the name of a distribution that takes a single parameter, returns random numbers
Y from the one-parameter family of distributions specified by name. Parameter values for the distribution are given in A.
Y = random(name,A,B) returns random numbers Y from a two-parameter family of distributions. Parameter values for
the distribution are given in A and B.
If A and B are arrays, they must be the same size. If either A or B are scalars, they are expanded to constant matrices
of the same size.
Y = random(name,A,B,C) returns random numbers Y from a three-parameter family of distributions. Parameter values
for the distribution are given in A, B, and C.
If A, B, and C are arrays, they must be the same size. If any of A, B, or C are scalars, they are expanded to constant
matrices of the same size.
Y = random(name,A,B,C,D) returns random numbers Y from a four-parameter family of distributions. Parameter values
for the distribution are given in A, B, C, and D.
If A, B, C, and D are arrays, they must be the same size. If any of A, B, C, or D are scalars, they are expanded to
constant matrices of the same size.
https://www.mathworks.com/help/stats/random.html?searchHighlight=random&s_tid=doc_srchtitle 1/4
2017. 8. 13. Random numbers - MATLAB random
Similarly, Y = random(name,A,B,m,n,...) or Y = random(name,A,B,[m,n,...]) returns an m-by-n-by... matrix of
random numbers for distributions that require two parameters. Y = random(name,A,B,C,m,n,...) or Y =
random(name,A,B,C,[m,n,...]) returns an m-by-n-by... matrix of random numbers for distributions that require three
parameters. Y = random(name,A,B,C,D,m,n,...) or Y = random(name,A,B,C,D,[m,n,...]) returns an m-by-n-by...
matrix of random numbers for distributions that require four parameters.
If any of A, B, C, or D are arrays, then the specified dimensions must match the common dimensions of A, B, C, and D
after any necessary scalar expansion.
The following table denotes the acceptable values for name, as well as the parameters for that distribution:
'birnbaumsaunders' Birnbaum- β γ — —
Saunders
Distribution
'loglogistic' Loglogistic μ σ — —
Distribution
https://www.mathworks.com/help/stats/random.html?searchHighlight=random&s_tid=doc_srchtitle 2/4
2017. 8. 13. Random numbers - MATLAB random
'logn' or Lognormal μ σ — —
'Lognormal' Distribution
'nakagami' Nakagami μ ω — —
Distribution
x1 = random('Normal',0,1,2,4)
x1 =
https://www.mathworks.com/help/stats/random.html?searchHighlight=random&s_tid=doc_srchtitle 3/4
2017. 8. 13. Random numbers - MATLAB random
Generate a single random value from Poisson distributions with rate parameters 1, 2, ..., 6, respectively.
x2 = random('Poisson',1:6,1,6)
x2 =
4 2 3 7 4 9
Extended Capabilities
See Also
cdf | fitdist | icdf | makedist | mle | pdf
Topics
Working with Probability Distributions
https://www.mathworks.com/help/stats/random.html?searchHighlight=random&s_tid=doc_srchtitle 4/4