From kas.hei at nbl.fi  Wed Feb 13 02:15:34 2008
From: kas.hei at nbl.fi (Heikki Kaskelma)
Date: Wed, 13 Feb 2008 03:15:34 +0200
Subject: [Rd] 0.45<0.45 = TRUE (PR#10744)
References: <1202827999.2701.19.camel@prometheus.geog.ucl.ac.uk><XFMail.080212153130.Ted.Harding@manchester.ac.uk>
	<f8e6ff050802121025w717ef902q7d186d0e1664845f@mail.gmail.com>
Message-ID: <fotgbo$n7m$2@ger.gmane.org>

hadley wickham:
> It's more than that as though, as floating point addition is no longer
> guaranteed to be commutative or associative, and multiplication does
> not distribute over addition.  Many concepts that are clear cut in
> pure math become fuzzy in floating point math - equality, singularity
> of matrices etc etc.

Even simple averages may be complicated:

eps=1
while(1-eps != 1) eps=eps/2
eps=eps*2

(1-1*eps+1-2*eps+1-3*eps)/3 == 1-1:3*eps    #  TRUE FALSE FALSE
mean(1-1:3*eps) == 1-1:3*eps    # FALSE  TRUE FALSE
sum(1-1:3*eps)/3 == 1-1:3*eps   # FALSE FALSE  TRUE
((1-1*eps)+(1-2*eps)+(1-3*eps))/3 == 1-1:3*eps   # FALSE FALSE  TRUE

so sometimes all the values may lie on the same side of the "average".

[Win R 2.6.1]


Heikki Kaskelma
Munkkiniemi, Finland



[Rd] 0.45<0.45 = TRUE (PR#10744)
Heikki Kaskelma