[R] Precision - or lack there of

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Dec 9 15:41:55 CET 2006


John Sorkin wrote:
> R 2.3.1
> Windows XP 
>
> I am surprised at the lack of precision in R, as noted below. I would
> expect the values to be closer to zero, particularly the later examples
> where the sample size is quite large.
>
>   
>> mean(rnorm(500,0,1))
>>     
> [1] -0.03209727
>   
>> mean(rnorm(5000,0,1))
>>     
> [1] -0.005991322
>   
>> mean(rnorm(50000,0,1))
>>     
> [1] -0.0006160524
>   
>> mean(rnorm(500000,0,1))
>>     
> [1] -0.001254309
>   
>> mean(rnorm(5000000,0,1))
>>     
> [1] 0.0004633778
>   
>> mean(rnorm(50000000,0,1))
>>     
> [1] -0.0001325764
>
> I would appreciate any thoughts. Is the lack of precision due to
> running on a 32-bit system?
>
> Thanks,
> John
>
>
> J

Looks OK to me. The theoretical SEM in the latter case is 
sqrt(1/5e7)==0.0001414214.




More information about the R-help mailing list