An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111208/903bf8ea/attachment.pl>
sum of deviations from the weighted mean
3 messages · andrija djurovic, michael.weylandt at gmail.com (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 <djandrija at gmail.com> 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) 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 got 0:
sum(x-mean(x))
[1] 0 Could someone explain me why we didn't get 0, with weighted mean, as it is expected? Thanks in advance Andrija [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111208/b155996a/attachment.pl>