randn() function command help

5 ビュー (過去 30 日間)
Nav
Nav 2020 年 7 月 10 日
コメント済み: dpb 2020 年 7 月 10 日
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

回答 (1 件)

dpb
dpb 2020 年 7 月 10 日
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 件のコメント
John D'Errico
John D'Errico 2020 年 7 月 10 日
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 2020 年 7 月 10 日
The fix is in... :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by