MATLAB 函数random()
(2011-04-10 10:05:29)
标签:
杂谈 |
分类: 学习 |
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) 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.
Acceptable strings for name are:
*
'beta' (Beta distribution)
*
'bino' (Binomial distribution)
*
'chi2' (Chi-square distribution)
*
'exp' (Exponential distribution)
*
'ev' (Extreme value distribution)
*
'f' (F distribution)
*
'gam' (Gamma distribution)
*
'gev' (Generalized extreme value distribution)
*
'gp' (Generalized Pareto distribution)
*
'geo' (Geometric distribution)
*
'hyge' (Hypergeometric distribution)
*
'logn' (Lognormal distribution)
*
'nbin' (Negative binomial distribution)
*
'ncf' (Noncentral F distribution)
*
'nct' (Noncentral tdistribution)
*
'ncx2' (Noncentral chi-square distribution)
*
'norm' (Normal distribution)
*
'poiss' (Poisson distribution)
*
'rayl' (Rayleigh distribution)
*
't' (t distribution)
*
'unif' (Uniform distribution)
*
'unid' (Discrete uniform distribution)
*
'wbl' (Weibull distribution)
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
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) 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.
Acceptable strings for name are:
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 =
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 =
See Also
cdf, pdf, icdf, mle
前一篇:如何写好论文(Word技巧版)
后一篇:Latex中的cls文件使用