| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
Y = random(name,A)
Y = random(name,A,B)
Y = random(name,A,B,C)
Y = random(...,m,n,...)
Y
= random(...,[m,n,...])
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 is the same size as 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(...,m,n,...) or Y = random(...,[m,n,...]) returns an m-by-n-by... matrix of random numbers.
If any of A, B, or C are arrays, then the specified dimensions must match the common dimensions of A, B, and C after any necessary scalar expansion.
The following table denotes the acceptable strings for name, as well as the parameters for that distribution:
| name | Distribution | Input Parameter A | Input Parameter B | Input Parameter C |
|---|---|---|---|---|
| 'beta' | Beta Distribution | a | b | — |
| 'bino' | Binomial Distribution | n: number of trials | p: probability of success for each trial | — |
| 'chi2' | Chi-Square Distribution | ν: degrees of freedom | — | — |
| 'exp' | Exponential Distribution | μ: mean | — | — |
| 'ev' | Extreme Value Distribution | μ: location parameter | σ: scale parameter | — |
| 'f' | F Distribution | ν1: numerator degrees of freedom | ν2: denominator degrees of freedom | — |
| 'gam' | Gamma Distribution | a: shape parameter | b: scale parameter | — |
| 'gev' | Generalized Extreme Value Distribution | K: shape parameter | μ: location parameter | σ: scale parameter |
| 'gp' | Generalized Pareto Distribution | k: tail index (shape) parameter | σ: scale parameter | μ: threshold (location) parameter |
| 'geo' | Geometric Distribution | p: probability parameter | — | — |
| 'hyge' | Hypergeometric Distribution | M: size of the population | K: number of items with the desired characteristic in the population | n: number of samples drawn |
| 'logn' | Lognormal Distribution | μ | σ | — |
| 'nbin' | Negative Binomial Distribution | r: number of successes | p: probability of success in a single trial | — |
| 'ncf' | Noncentral F Distribution | ν1: numerator degrees of freedom | ν2: denominator degrees of freedom | δ: noncentrality parameter |
| 'nct' | Noncentral t Distribution | ν: degrees of freedom | δ: noncentrality parameter | — |
| 'ncx2' | Noncentral Chi-Square Distribution | ν: degrees of freedom | δ: noncentrality parameter | — |
| 'norm' | Normal Distribution | μ: mean | σ: standard deviation | — |
| 'poiss' | Poisson Distribution | λ: mean | — | — |
| 'rayl' | Rayleigh Distribution | b: scale parameter | — | — |
| 't' | Student's t Distribution | ν: degrees of freedom | — | — |
| 'unif' | Uniform Distribution (Continuous) | a: lower endpoint (minimum) | b: upper endpoint (maximum) | — |
| 'unid' | Uniform Distribution (Discrete) | N: maximum observable value | — | — |
| 'wbl' | Weibull Distribution | a: scale parameter | b: shape parameter | — |
Generate a 2-by-4 array of random values from the normal distribution with mean 0 and standard deviation 1:
x1 = random('Normal',0,1,2,4)
x1 =
1.1650 0.0751 -0.6965 0.0591
0.6268 0.3516 1.6961 1.7971
The order of the parameters is the same as for normrnd.
Generate a single random value from Poisson distributions with rate parameters 1, 2, ..., 6, respectively:
x2 = random('Poisson',1:6,1,6)
x2 =
0 0 1 2 5 7![]() | randg | random (gmdistribution) | ![]() |

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 |