From: Ted Harding <ted.harding_at_nessie.mcc.ac.uk>

Date: Mon, 03 Sep 2007 18:50:28 +0100 (BST)

*>
*

*> Quiz: What about utility functions equalsE() and equalsPi()?
*

> ...together with examples illustrating when they return TRUE and when

*> they return FALSE.
*

*>
*

*> Cheers
*

*>
*

*> /Henrik
*

...

(these work in R)

E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 03 Sep 2007 - 17:54:49 GMT

Date: Mon, 03 Sep 2007 18:50:28 +0100 (BST)

On 03-Sep-07 15:12:06, Henrik Bengtsson wrote:

> On 9/2/07, marco.vicentini_at_gmail.com <marco.vicentini_at_gmail.com> wrote:

>> [...] >> If it may be usefull, I have written to small function >> (Unique and isEqual) >> which can deal with this problem of the double numbers.

> ...together with examples illustrating when they return TRUE and when

Well, if you guys want a Quiz: ... My favourite example of something which will probably never work on R (or any machine which implements fixed-length binary real arithmetic).

An interated function scheme on [0,1] is defined by

if 0 <= x <= 0.5 then next x = 2*x

if 0.5 < x <= 1 then next x = 2*(1 - x)

in R:

nextX <- function(x){ifelse(x<=0.5, 2*x, 2*(1-x))}

x<-3/7; for(i in (1:60)){x<-nextX(x); print(c(i,x))}

x = 0 is an absorbing state. x = 1 -> x = 0 x = 1/2 -> 1 -> 0

...

(these work in R)

If K is an odd integer, and 0 < r < K, then

x = r/K -> ... leads into a periodic set.

E.g. (see above) 3/7 -> 6/7 -> 2/7 -> 4/7 -> 2/7

All other numbers x outside these sets generate non-periodic sequences.

Apart from the case where initial x = 1/2^k, none of the above is true in R (e.g. the example above).

So can you devise an "isEqual" function which will make this work?

It's only Monday .. plenty of time!

Best wishes,

Ted.

E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861

Date: 03-Sep-07 Time: 17:32:38 ------------------------------ XFMail ------------------------------ --------------------------------------------------------------------E-Mail: (Ted Harding) <ted.harding_at_nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861

Date: 03-Sep-07 Time: 18:50:23 ------------------------------ XFMail ------------------------------ ______________________________________________R-devel_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 03 Sep 2007 - 17:54:49 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 03 Sep 2007 - 21:40:39 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel.
Please read the posting
guide before posting to the list.
*