Re: [R] Logical inconsistency

2008-12-11 Thread Kenn Konstabel
[EMAIL PROTECTED] Cc: R help [EMAIL PROTECTED] Sent: Tuesday, 9 December, 2008 16:30:08 Subject: RE: [R] Logical inconsistency Some (possibly all) of those numbers cannot be represented exactly, so there is a chance of round off error whenever you do some arithmetic, sometimes the errors

Re: [R] Logical inconsistency

2008-12-11 Thread Bernardo Rangel Tura
PROTECTED] Sent: Thu, 11 Dec 2008 11:53:01 +0200 Subject: Re: [R] Logical inconsistency Rounding can do no good because round(8.8,1)-round(7.8,1)1 # still TRUE round(8.8)-round(7.7)1 # FALSE What you might do is compute a-b-1 and compare it to a very small number: (8.8-7.8-1) 1e-10

Re: [R] Logical inconsistency

2008-12-11 Thread Kenn Konstabel
PROTECTED] Sent: Thu, 11 Dec 2008 11:53:01 +0200 Subject: Re: [R] Logical inconsistency Rounding can do no good because round(8.8,1)-round(7.8,1)1 # still TRUE round(8.8)-round(7.7)1 # FALSE What you might do is compute a-b-1 and compare it to a very small number: (8.8-7.8-1

Re: [R] Logical inconsistency

2008-12-11 Thread Bernardo Rangel Tura
On Thu, 2008-12-11 at 17:23 +0200, Kenn Konstabel wrote: Hi, I agree -- and my examples using round were meant as bad and dangerous examples. Using round at the last step is better and may solve the problem, but in your example ... round(8.8-7.8,1)==1 [1] TRUE ... you have to know in

Re: [R] Logical inconsistency

2008-12-10 Thread emma jane
]; Chuck Cleland [EMAIL PROTECTED] Cc: R help [EMAIL PROTECTED] Sent: Tuesday, 9 December, 2008 16:30:08 Subject: RE: [R] Logical inconsistency Some (possibly all) of those numbers cannot be represented exactly, so there is a chance of round off error whenever you do some arithmetic, sometimes

Re: [R] Logical inconsistency

2008-12-10 Thread Stephan Kolassa
Of emma jane Sent: Tuesday, December 09, 2008 7:02 AM To: Bernardo Rangel Tura; Wacek Kusnierczyk; Chuck Cleland Cc: R help Subject: Re: [R] Logical inconsistency Many thanks for your help, perhaps I should have set my query in context ! I'm simply calculating an indicator variable [0,1] based

Re: [R] Logical inconsistency

2008-12-10 Thread Gustavo Carvalho
] .com.br; Wacek Kusnierczyk [EMAIL PROTECTED]; Chuck Cleland [EMAIL PROTECTED] Cc: R help [EMAIL PROTECTED] Sent: Tuesday, 9 December, 2008 16:30:08 Subject: RE: [R] Logical inconsistency Some (possibly all) of those numbers cannot be represented exactly, so there is a chance of round off error

Re: [R] Logical inconsistency

2008-12-10 Thread Bernardo Rangel Tura
On Tue, 2008-12-09 at 06:02 -0800, emma jane wrote: Many thanks for your help, perhaps I should have set my query in context ! I'm simply calculating an indicator variable [0,1] based on the whether the difference between two measured variables is 1 or =1. I understand the FAQ

Re: [R] Logical inconsistency

2008-12-09 Thread emma jane
[EMAIL PROTECTED] Sent: Saturday, 6 December, 2008 10:00:48 Subject: Re: [R] Logical inconsistency On Fri, 2008-12-05 at 14:18 +0100, Wacek Kusnierczyk wrote: Berwin A Turlach wrote: Dear Emma, On Fri, 5 Dec 2008 04:23:53 -0800 (PST)     Please could someone kindly explain

Re: [R] Logical inconsistency

2008-12-09 Thread Greg Snow
: Tuesday, December 09, 2008 7:02 AM To: Bernardo Rangel Tura; Wacek Kusnierczyk; Chuck Cleland Cc: R help Subject: Re: [R] Logical inconsistency Many thanks for your help, perhaps I should have set my query in context ! I'm simply calculating an indicator variable [0,1] based

Re: [R] Logical inconsistency

2008-12-09 Thread Wacek Kusnierczyk
Patrick Connolly wrote: On Mon, 08-Dec-2008 at 02:05AM +0800, Berwin A Turlach wrote: | G'day Wacek, | | On Sat, 06 Dec 2008 10:49:24 +0100 | Wacek Kusnierczyk [EMAIL PROTECTED] wrote: | | [] | there is, in principle, no problem in having a high-level language | perform the

Re: [R] Logical inconsistency

2008-12-09 Thread Mark Difford
And here one is very much inclined to chirp in and say, A matchless Wacek strikes again. Regards, and thanks to all for a most entertaining (and enlightening) thread. Wacek Kusnierczyk wrote: Patrick Connolly wrote: On Mon, 08-Dec-2008 at 02:05AM +0800, Berwin A Turlach wrote: | G'day

Re: [R] Logical inconsistency

2008-12-08 Thread Wacek Kusnierczyk
Patrick Connolly wrote: On Mon, 08-Dec-2008 at 02:05AM +0800, Berwin A Turlach wrote: | G'day Wacek, | | On Sat, 06 Dec 2008 10:49:24 +0100 | Wacek Kusnierczyk [EMAIL PROTECTED] wrote: | | [] | there is, in principle, no problem in having a high-level language | perform the

Re: [R] Logical inconsistency

2008-12-08 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: I am not surprised about CS guys never learning about these issues. As long as you play around with data bases (their organisation c), sorting algorithms, artificial intelligence (at least when I attended a lecture on this) you do not need to know about these issues.

Re: [R] Logical inconsistency

2008-12-08 Thread Berwin A Turlach
G'day Wacek, On Mon, 08 Dec 2008 13:13:33 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: Berwin A Turlach wrote: I am not surprised about CS guys never learning about these issues. As long as you play around with data bases (their organisation c), sorting algorithms, artificial

Re: [R] Logical inconsistency

2008-12-08 Thread Berwin A Turlach
G'day Wacek, On Sun, 07 Dec 2008 21:09:36 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: g'evening. Not the done thing. c'mon, a person from central europe can't possibly be unaware of this joke. I wouldn't call Norway central Europe, but then I also guess that you are not really

Re: [R] logical inconsistency

2008-12-07 Thread Peter Dalgaard
John C Nash wrote: This actually goes back a very long way. Peter is right to remind us that optimizers (in the sense of compilers) can corrupt algorithms that are well-designed. Optimizing in tests is something some of us have fought for nearly 40 years, but compiler writers don't do much

Re: [R] Logical inconsistency

2008-12-07 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: On Sat, Dec 6, 2008 at 4:32 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: Stavros Macrakis wrote: On Sat, Dec 6, 2008 at 5:02 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: yepp, though (2/3)*3 not evaluating to 2 is again not a must, is it.

Re: [R] Logical inconsistency

2008-12-07 Thread Berwin A Turlach
G'day Wacek, On Sat, 06 Dec 2008 10:49:24 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: [] there is, in principle, no problem in having a high-level language perform the computation in a logically consistent way. Is this now supposed to be a Radio Eriwan joke? As another saying

Re: [R] Logical inconsistency

2008-12-07 Thread Charles C. Berry
On Mon, 8 Dec 2008, Berwin A Turlach wrote: G'day Wacek, On Sat, 06 Dec 2008 10:49:24 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: [] there is, in principle, no problem in having a high-level language perform the computation in a logically consistent way. Is this now supposed to be

Re: [R] Logical inconsistency

2008-12-07 Thread Ted Harding
On 07-Dec-08 18:41:16, Charles C. Berry wrote: On Mon, 8 Dec 2008, Berwin A Turlach wrote: G'day Wacek, On Sat, 06 Dec 2008 10:49:24 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: [] there is, in principle, no problem in having a high-level language perform the computation in a

Re: [R] Logical inconsistency

2008-12-07 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: G'day Wacek, g'evening. On Sat, 06 Dec 2008 10:49:24 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: [] there is, in principle, no problem in having a high-level language perform the computation in a logically consistent way. Is this now

Re: [R] Logical inconsistency

2008-12-07 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: On Sun, Dec 7, 2008 at 3:51 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: (* (/ 2.0 3.0) 3.0) is not exact either, as aren't (* (/ 2.0 2.0) 2.0)... Actually, they *are* all exact in any system using IEEE floats. not per definitionem of

Re: [R] Logical inconsistency

2008-12-07 Thread Patrick Connolly
On Mon, 08-Dec-2008 at 02:05AM +0800, Berwin A Turlach wrote: | G'day Wacek, | | On Sat, 06 Dec 2008 10:49:24 +0100 | Wacek Kusnierczyk [EMAIL PROTECTED] wrote: | | [] | there is, in principle, no problem in having a high-level language | perform the computation in a logically

Re: [R] Logical inconsistency

2008-12-06 Thread Stavros Macrakis
On Fri, Dec 5, 2008 at 8:18 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: well, this answer the question only partially. this explains why a system with finite precision arithmetic, such as r, will fail to be logically correct in certain cases. it does not explain why r, a language said

Re: [R] Logical inconsistency

2008-12-06 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: G'day Wacek, On Fri, 05 Dec 2008 14:18:51 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: well, this answer the question only partially. this explains why a system with finite precision arithmetic, such as r, will fail to be logically correct in certain cases.

Re: [R] Logical inconsistency

2008-12-06 Thread Bernardo Rangel Tura
On Fri, 2008-12-05 at 14:18 +0100, Wacek Kusnierczyk wrote: Berwin A Turlach wrote: Dear Emma, On Fri, 5 Dec 2008 04:23:53 -0800 (PST) emma jane [EMAIL PROTECTED] wrote: Please could someone kindly explain the following inconsistencies I've discovered__when performing logical

Re: [R] Logical inconsistency

2008-12-06 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: On Fri, Dec 5, 2008 at 8:18 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: well, this answer the question only partially. this explains why a system with finite precision arithmetic, such as r, will fail to be logically correct in certain cases. it does not

Re: [R] Logical inconsistency

2008-12-06 Thread Stavros Macrakis
On Sat, Dec 6, 2008 at 5:02 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: yepp, though (2/3)*3 not evaluating to 2 is again not a must, is it. Why is that less a must than .3-.2 == .1? On the contrary, the computing convention (and for that matter the usual scientific and engineering

Re: [R] Logical inconsistency

2008-12-06 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: On Sat, Dec 6, 2008 at 5:02 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: yepp, though (2/3)*3 not evaluating to 2 is again not a must, is it. Why is that less a must than .3-.2 == .1? On the contrary, the computing convention (and for that matter the

Re: [R] Logical inconsistency

2008-12-06 Thread Stavros Macrakis
On Sat, Dec 6, 2008 at 4:32 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: Stavros Macrakis wrote: On Sat, Dec 6, 2008 at 5:02 AM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: yepp, though (2/3)*3 not evaluating to 2 is again not a must, is it. Why is that less a must than .3-.2 == .1?

Re: [R] logical inconsistency

2008-12-06 Thread nashjc
This comment is orthogonal to most of the others. It seems that folk often want to test for equality of real numbers. One important one is for convergence tests. When writing my Compact Numerical Methods book I had to avoid lots of logical tests, but wanted to compare two REALs. I found that the

Re: [R] logical inconsistency

2008-12-06 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote: This comment is orthogonal to most of the others. It seems that folk often want to test for equality of real numbers. One important one is for convergence tests. When writing my Compact Numerical Methods book I had to avoid lots of logical tests, but wanted to compare

Re: [R] logical inconsistency

2008-12-06 Thread John C Nash
This actually goes back a very long way. Peter is right to remind us that optimizers (in the sense of compilers) can corrupt algorithms that are well-designed. Optimizing in tests is something some of us have fought for nearly 40 years, but compiler writers don't do much floating-point

[R] Logical inconsistency

2008-12-05 Thread emma jane
Dear colleagues Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1 TRUE Thank you, Emma Jane [[alternative HTML version deleted]]

Re: [R] Logical inconsistency

2008-12-05 Thread Chuck Cleland
On 12/5/2008 7:23 AM, emma jane wrote: Dear colleagues Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1 TRUE See R FAQ 7.31

Re: [R] Logical inconsistency

2008-12-05 Thread Berwin A Turlach
Dear Emma, On Fri, 5 Dec 2008 04:23:53 -0800 (PST) emma jane [EMAIL PROTECTED] wrote: Please could someone kindly explain the following inconsistencies I've discovered__when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1 TRUE Gladly: FAQ 7.31

Re: [R] Logical inconsistency

2008-12-05 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: Dear Emma, On Fri, 5 Dec 2008 04:23:53 -0800 (PST) emma jane [EMAIL PROTECTED] wrote: Please could someone kindly explain the following inconsistencies I've discovered__when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1

Re: [R] Logical inconsistency

2008-12-05 Thread Berwin A Turlach
G'day Wacek, On Fri, 05 Dec 2008 14:18:51 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: well, this answer the question only partially. this explains why a system with finite precision arithmetic, such as r, will fail to be logically correct in certain cases. it does not explain why r, a