[R] Precision - or lack there of
Duncan Murdoch
murdoch at stats.uwo.ca
Sat Dec 9 17:39:10 CET 2006
On 12/9/2006 9:26 AM, 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.
These are all cases where the theoretical distributions are easy to
calculate, and the results you are getting are not particularly unusual:
>
>> mean(rnorm(500,0,1))
> [1] -0.03209727
> pnorm(-0.03209727, sd=1/sqrt(500))
[1] 0.2364660
>> mean(rnorm(5000,0,1))
> [1] -0.005991322
> pnorm(-0.005991322, sd=1/sqrt(5000))
[1] 0.3359104
[skipped some]
>> 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
> pnorm(-0.0001325764, sd=1/sqrt(50000000))
[1] 0.1742618
>
> I would appreciate any thoughts. Is the lack of precision due to
> running on a 32-bit system?
No, the lack of precision seems to be due to the distributions you are
sampling from.
Duncan Murdoch
>
> Thanks,
> John
>
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> Baltimore VA Medical Center GRECC,
> University of Maryland School of Medicine Claude D. Pepper OAIC,
> University of Maryland Clinical Nutrition Research Unit, and
> Baltimore VA Center Stroke of Excellence
>
> University of Maryland School of Medicine
> Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
>
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> jsorkin at grecc.umaryland.edu
>
> Confidentiality Statement:
> This email message, including any attachments, is for the so...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list