randn function with so many digits or huge numbers
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Sean de Wolski
2014년 4월 29일
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
Sean de Wolski
2014년 4월 29일
Oh and if you want to grow an array of identical values
zeros(10,1)
ones(10,1)
Metin
2014년 4월 29일
Sean de Wolski
2014년 4월 29일
round off error in the floating point calculations of standard deviation.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!