[R] computing the variance

Wang Tian Hua wangth at bii-sg.org
Mon Dec 5 09:53:00 CET 2005


hi,
when i was computing the variance of a simple vector, i found unexpect 
result. not sure whether it is a bug.
 > var(c(1,2,3))
[1] 1  #which should be 2/3.
 > var(c(1,2,3,4,5))
[1] 2.5 #which should be 10/5=2

it seems to me that the program uses (sample size -1) instead of sample 
size at the denominator. how can i rectify this?

regards,
tianhua




More information about the R-help mailing list