randn() function command help

2 Ansichten (letzte 30 Tage)
Nav
Nav am 10 Jul. 2020
Kommentiert: dpb am 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

Antworten (1)

dpb
dpb am 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 Kommentare
John D'Errico
John D'Errico am 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 am 10 Jul. 2020
The fix is in... :)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by