Categories &

Functions List

Function Reference: random

statistics: r = random (name, A)
statistics: r = random (name, A, B)
statistics: r = random (name, A, B, C)
statistics: r = random (name, …, rows, cols)
statistics: r = random (name, …, rows, cols, …)
statistics: r = random (name, …, [sz])

Random arrays from a given one-, two-, or three-parameter distribution.

The variable name must be a string with the name of the distribution to sample from. If this distribution is a one-parameter distribution, A must be supplied, if it is a two-parameter distribution, B must also be supplied, and if it is a three-parameter distribution, C must also be supplied. Any arguments following the distribution parameters will determine the size of the result.

When called with a single size argument, return a square matrix with the dimension specified. When called with more than one scalar argument the first two arguments are taken as the number of rows and columns and any further arguments specify additional matrix dimensions. The size may also be specified with a vector of dimensions sz.

name must be a char string of the name or the abbreviation of the desired probability distribution function as listed in the following table. The last column shows the required number of parameters that must be passed to the desired *rnd distribution function.

Distribution NameAbbreviationInput Parameters
'Beta''beta'2
'Binomial''bino'2
'Birnbaum-Saunders''bisa'2
'Burr''burr'3
'Cauchy''cauchy'2
'Chi-squared''chi2'1
'Extreme Value''ev'2
'Exponential''exp'1
'F-Distribution''f'2
'Gamma''gam'2
'Geometric''geo'1
'Generalized Extreme Value''gev'3
'Generalized Pareto''gp'3
'Gumbel''gumbel'2
'Half-normal''hn'2
'Hypergeometric''hyge'3
'Inverse Gaussian''invg'2
'Laplace''laplace'2
'Logistic''logi'2
'Log-Logistic''logl'2
'Lognormal''logn'2
'Nakagami''naka'2
'Negative Binomial''nbin'2
'Noncentral F-Distribution''ncf'3
'Noncentral Student T''nct'2
'Noncentral Chi-Squared''ncx2'2
'Normal''norm'2
'Poisson''poiss'1
'Rayleigh''rayl'1
'Rician''rice'2
'Student T''t'1
'location-scale T''tls'3
'Triangular''tri'3
'Discrete Uniform''unid'1
'Uniform''unif'2
'Von Mises''vm'2
'Weibull''wbl'2

Source Code: random

Distribution names are matched ignoring case, spaces and hyphens, so that 'Extreme Value', 'ExtremeValue' and 'extreme-value' all select the same distribution, and the same set of names is accepted by cdf, pdf, icdf, random, makedist, fitdist and mle.

This accepts more names than MATLAB. MATLAB takes the spaced and the squashed spelling but refuses the hyphenated one, so 'Birnbaum-Saunders' and 'Log-Logistic' are errors there; Octave has always accepted them and continues to. MATLAB also accepts 'tLocationScale' in makedist while refusing it in cdf for the same distribution; Octave accepts it, and 'location-scale T', everywhere. Code written against MATLAB’s names therefore runs unchanged, but code relying on these names will not port back.

See also: cdf, icdf, pdf, betarnd, binornd, bisarnd, burrrnd, cauchyrnd, chi2rnd, evrnd, exprnd, frnd, gamrnd, geornd, gevrnd, gprnd, gumbelrnd, hnrnd, hygernd, invgrnd, laplacernd, logirnd, loglrnd, lognrnd, nakarnd, nbinrnd, ncfrnd, nctrnd, ncx2rnd, normrnd, poissrnd, raylrnd, ricernd, trnd, tlsrnd, trirnd, unidrnd, unifrnd, vmrnd, wblrnd

Source Code: random