randn function with so many digits or huge numbers
Mostrar comentarios más antiguos
Hallo my question is about generating normal distributed random numbers with randn function of MATLAB, e.g.
x=25.589665545.*(1+0*randn(100,1));
std(x)
ans =
1.7853e-014
or with huge numbers :
y=10^25.*(1+0*randn(10000,1));
std(y)
ans =1.0631e+012
is that not strange? to be sure there are some other ways to generate array with constant numbers, but I see this when I want to generate variables with different deviations, for any command pthanks in advance
Respuesta aceptada
Más respuestas (1)
Sean de Wolski
el 29 de Abr. de 2014
Not strange at all!
(1+0*randn(10,1))
Note the zero times randn - all of those components are zero. The very small standard deviation is pretty close to the eps(x) so it's just roundoff error in the calculation of x.
4 comentarios
Sean de Wolski
el 29 de Abr. de 2014
Oh and if you want to grow an array of identical values
zeros(10,1)
ones(10,1)
Metin
el 29 de Abr. de 2014
Sean de Wolski
el 29 de Abr. de 2014
round off error in the floating point calculations of standard deviation.
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!