randn function with so many digits or huge numbers
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 29 Apr. 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 Kommentare
Sean de Wolski
am 29 Apr. 2014
Oh and if you want to grow an array of identical values
zeros(10,1)
ones(10,1)
Metin
am 29 Apr. 2014
Sean de Wolski
am 29 Apr. 2014
round off error in the floating point calculations of standard deviation.
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!