randn() function command help

4 views (last 30 days)
Nav
Nav on 10 Jul 2020
Commented: dpb on 10 Jul 2020
I am currently trying to learn MATLAB independently and had a question about a command that used randn().
nddata = fix(8*randn(10,5,3))
I understand what the fix() function does, and the multidimension array that is created by randn. However, I am not sure what 8 is doing here, it is not multiplying the outcome of the random numbers and it is not part of the limit. So I just want to know the purpose of the 8 here.
Thanks

Answers (1)

dpb
dpb on 10 Jul 2020
nddata = fix(8*randn(10,5,3))
"... I am not sure what 8 is doing here, it is not multiplying the outcome of the random numbers ..."
What makes you think that???
Of course it is.
That's the purpose; the originator of the code wanted that scaling on a RNVariate sample. Why would want to fix() the result is perhaps the more interesting Q? but undoubtedly had something to do with the particulars of the simulation model.
  2 Comments
John D'Errico
John D'Errico on 10 Jul 2020
Exactly the one thing we DO know about that line is it is indeed mutiplying by 8. Fix, as applied to normally distributed numbers is a bit more interesting, but taken out of context, it is impossible to know why the fix is in there. Only the person who wrote the line.
randn produces Gaussian random numbers, with mean 0 and a population standard deviation = 1. Therefore, if you multiply by 8, the sample now has still mean zero, but the population standard deviation is 8.
The fix just produces something strange. :)
dpb
dpb on 10 Jul 2020
The fix is in... :)

Sign in to comment.

Categories

Find more on Random Number Generation in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!