MATLAB: Multiple runs of normrnd vs. one run of normrnd with several outputs

normrnd normal distribution random

Say that i have a certain mu and sigma
Is normrnd(mu,sigma,1,10) the same as doing normrnd(mu,sigma) 10 times?

Best Answer

Yes. But why not test it yourself?
rng(17)
normrnd(0,1)
ans =
-0.39509
normrnd(0,1)
ans =
0.14056
normrnd(0,1)
ans =
-1.5172
As you can see, these are the first three elements of the next call.
rng(17)
normrnd(0,1,[10,1])
ans =
-0.39509
0.14056
-1.5172
-1.882
0.79651
0.24127
0.28683
0.26861
-2.1682
-0.15616
normrnd(0,1,[10,1])
ans =
1.7974
-1.4667
0.3709
0.78102
-1.3599
0.34756
0.084283
0.23211
-0.043727
-0.09342
rng(17)
normrnd(0,1,[10,2])
ans =
-0.39509 1.7974
0.14056 -1.4667
-1.5172 0.3709
-1.882 0.78102
0.79651 -1.3599
0.24127 0.34756
0.28683 0.084283
0.26861 0.23211
-2.1682 -0.043727
-0.15616 -0.09342
Note that I created them as column vectors so you can see the stream of numbers is indeed the same. Had I created the array as 2x10, the numbers would have been the same, but they would have been stuffed in the array in a different sequence. But this is just a question of how MATLAB stores the elements in an array.