randn() function command help

2 visualizaciones (últimos 30 días)
Nav
Nav el 10 de Jul. de 2020
Comentada: dpb el 10 de Jul. de 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

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by