MATLAB functions
RANDN: A function of a random number or matrix that produces a normal distribution
RANDN: Generates a mean value of 0, the variance σ^2 = 1, the standard deviation σ = 1 of the normal distribution of the random number or matrix function.
Usage:
Y = RANDN (n): Returns the matrix of a n*n random item. If n is not a quantity, an error message is returned.
y = Randn (m,n) or y = randn ([M n]): Returns a random item matrix of M*n.
Y = Randn (m,n,p,...) or Y = Randn ([m n p ...]) : Generates a random array.
Y = Randn (Size (A)): Returns a random array with the same dimension size as a.
Randn
Returns a quantity that changes every time.
s = randn (' state ')
Example
Example 1. R = Randn (3,4) will generate the matrix
R =
1.1650 0.3516 0.0591 0.8717
0.6268-0.6965 1.7971-1.4462
0.0751 1.6961 0.2641-0.7012
For a histogram of the RANDN distribution, see Hist.
Example 2. produces a randomly distributed matrix of specified mean and variance: Multiply the result of the RANDN by the standard deviation, and then add the desired mean. For example, the random number of a 5*5 with a mean of 0.6 and a variance of 0.1 is as follows:
x =. 6 + sqrt (0.1) * RANDN (5)
x =
0.8713 0.4735 0.8114) 0.0927 0.7672
0.9966 0.8182 0.9766) 0.6814 0.6694
0.0960 0.8579 0.2197) 0.2659 0.3085
0.1443 0.8251 0.5937 1.0475-0.0864
0.7806 1.0080 0.5504) 0.3454 0.5813
Other similar functions:rand, Randperm, Sprand, Sprandn
a uniformly distributed random number or matrix
Grammar
Y = rand (n)
Y = rand (m,n)
Y = rand ([M n])
Y = rand (m,n,p,...)
Y = rand ([m n p ...])
Y = rand (Size (A))
Rand
s = rand (' state ')
Describe
The RAND function is generated by theAn array of random numbers evenly distributed between (0, 1)
Y = rand (n)Returns aA random matrix of n x N ifn is not a quantity, then an error message is returned
Y = rand (m,n)OrY = rand ([M n])Returns aRandom matrices of M x n
Y = rand (m,n,p,...)OrY = rand ([m n p ...])Generating a random array
Y = rand (Size (A))Returns a andA random matrix with the same size
1,RAND (3) *-2 rand (3) is aA random matrix of 3*3 (the range of values inBetween 0~1) then is each number of times on -2
2  matlab randomly generated 60 1 to 365 positive number 1+fix (365*rand (1,60);
3, randomly taken with rand function 100 from -1 to 1 number x1, x2,..., x = rand (1,100) * 2-1
Randn functions in MATLAB