Re: [R] sum of deviations from the weighted mean

2011-12-08 Thread andrija djurovic
Thank and sorry i should check this before asking the question. Andrija On Thu, Dec 8, 2011 at 3:20 PM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > R FAQ 7.31 I'd imagine. (Floating point arithmetic and limitations thereof) > > Michael > > On Dec 8, 2011, at 9:15 AM, andrija djur

Re: [R] sum of deviations from the weighted mean

2011-12-08 Thread R. Michael Weylandt
R FAQ 7.31 I'd imagine. (Floating point arithmetic and limitations thereof) Michael On Dec 8, 2011, at 9:15 AM, andrija djurovic wrote: > Hi all. I tried to calculate sum of deviations from the weighted mean and i > didn't get what i expected - 0. Here is an example: > >> wt <- c(10,25,38,22,5

[R] sum of deviations from the weighted mean

2011-12-08 Thread andrija djurovic
Hi all. I tried to calculate sum of deviations from the weighted mean and i didn't get what i expected - 0. Here is an example: > wt <- c(10,25,38,22,5) > x <- 6:10 > wm <- weighted.mean(x,wt) > (x-wm)*wt [1] -18.70 -21.75 4.94 24.86 10.65 > sum((x-wm)*wt) [1] -1.24345e-14 With simple mean I