randnPseudo-random number following the standard normal distribution
randnrandn(n)n-by-n matrix of pseudo-random numbers following the standard normal distribution.n should be a real, non-negative integer scalar. If n is zero, it returns an empty array.randn(s1,s2,...,sN)s1, s2, ..., sN], which contains pseudo-random numbers following the standard normal distribution.s1, s2, ..., sN should be real, non-negative integer scalars. If one of s1, s2, ..., sN is zero, it returns an empty array.randn(sizeVec)sizeVec.sizeVec should contain real, non-negative elements. If an element of sizeVec is zero, it returns an empty array.randn (in Line 2). Then, we estimate the mean and standard deviation from the samples. We find that % Vector of numbers from normal distribution with mean equal to 1 and SD equal to 2.
r = 2 * randn(1,100000) + 1;
% Mean estimated from r.
mean(r)
% Standard deviation estimated from r.
sqrt(mean((1-r).^2))
ans = 1e-1 ×
9.9262
ans =
2.0067