Re: [Rd] [R] computing the variance

2005-12-05 Thread Thomas Lumley
> > Using the biased variance just because it is the MLE (if that is the > argument) seems confused to me. However, there's another point: > >> var(sample(1:3, 10, replace=TRUE)) > [1] 0.6680556 > > i.e. if we are considering x as the entire population, then the > variance when sampling from it

Re: [Rd] [R] computing the variance

2005-12-05 Thread Ted Harding
On 05-Dec-05 Duncan Murdoch wrote: >> The variance of X is (or damn well should be) defined as >> >> Var(X) = E(X^2) - (E(X))^2 >> >> and this comes to (Sum(X^2) - (Sum(X)/N)^2))/(N-1). > > I don't follow this. I agree with the first line (though I prefer to > write it differently), but I do

Re: [Rd] [R] computing the variance

2005-12-05 Thread Duncan Murdoch
On 12/5/2005 2:25 PM, (Ted Harding) wrote: > On 05-Dec-05 Martin Maechler wrote: >> UweL> x <- c(1,2,3,4,5) >> UweL> n <- length(x) >> UweL> var(x)*(n-1)/n >> >> UweL> if you really want it. >> >> It seems Insightful at some point in time have given in to >> this user request, and

Re: [Rd] [R] computing the variance

2005-12-05 Thread Peter Dalgaard
Martin Maechler <[EMAIL PROTECTED]> writes: > It seems Insightful at some point in time have given in to > this user request, and S-plus nowadays has > an argument "unbiased = TRUE" > where the user can choose {to shoot (him/her)self in the leg and} > require 'unbiased = FALSE'. > {and there's al

Re: [Rd] [R] computing the variance

2005-12-05 Thread Ted Harding
On 05-Dec-05 Martin Maechler wrote: > UweL> x <- c(1,2,3,4,5) > UweL> n <- length(x) > UweL> var(x)*(n-1)/n > > UweL> if you really want it. > > It seems Insightful at some point in time have given in to > this user request, and S-plus nowadays has > an argument "unbiased = TRUE"

Re: [Rd] [R] computing the variance

2005-12-05 Thread Martin Maechler
{from R-help, diverted to R-devel}: UweL> Wang Tian Hua wrote: UweL> hi, when i was computing the variance of a simple UweL> vector, i found unexpect result. not sure whether it UweL> is a bug. UweL> Not a bug! ?var: UweL> "The denominator n - 1 is used which gives an un