Skip to content
Prev 19516 / 63424 Next

Computing means, variances and sums

This is drifting a bit off topic, but the other day I discovered this
rather nice illustration of the perils of finite precision arithmetic
while creating a contrast matrix:
[1]  2.775558e-16  2.775558e-16  5.551115e-17  5.551115e-17  5.551115e-17
 [6]  5.551115e-17  0.000000e+00 -5.551115e-17  0.000000e+00  5.551115e-17
[11]  1.110223e-16  1.665335e-16  2.220446e-16

Not only do most of the rows not sum to 0, they do not even sum to the
same number!  It is hard to remember the familiar rules of arithmetic
do not always apply.

Hadley