Products & Services Industries Academia Support User Community Company

Learn more about Statistics Toolbox   

random - Random numbers

Syntax

Y = random(name,A)
Y = random(name,A,B)
Y = random(name,A,B,C)
Y = random(...,m,n,...)
Y = random(...,[m,n,...])

Description

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:

nameDistributionInput Parameter AInput Parameter BInput Parameter C
'beta'Beta Distributionab
'bino'Binomial Distributionn: number of trialsp: 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 Distributiona: shape parameterb: scale parameter
'gev'Generalized Extreme Value DistributionK: shape parameterμ: location parameterσ: scale parameter
'gp'Generalized Pareto Distributionk: tail index (shape) parameterσ: scale parameterμ: threshold (location) parameter
'geo'Geometric Distributionp: probability parameter
'hyge'Hypergeometric DistributionM: size of the populationK: number of items with the desired characteristic in the populationn: number of samples drawn
'logn'Lognormal Distributionμσ
'nbin'Negative Binomial Distributionr: number of successesp: 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 Distributionb: 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 Distributiona: scale parameterb: shape parameter

Examples

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

See Also

cdf, pdf, icdf, mle

  


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