Re: [R] That dreaded floating point trap

From: ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be>
Date: Thu, 31 Mar 2011 13:17:25 +0000

Dear Alexander,

Instead of testing 'somevector > 0.4', test 'abs(somevector - 0.4) < some.small.number'

Best regards,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx_at_inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey   

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] Namens Alexander Engelhardt
> Verzonden: donderdag 31 maart 2011 14:57
> Aan: r-help_at_r-project.org
> Onderwerp: Re: [R] That dreaded floating point trap
>
> Am 31.03.2011 14:41, schrieb Sarah Goslee:
> > On Thu, Mar 31, 2011 at 8:14 AM, Alexander Engelhardt
> >> this helps, thank you.
> >> But if this code is in a function, and some user supplies
> a vector, I
> >> will still have to round it in the function, I guess.
> >>
> >> It's weird how 0.1 is different from round(0.1, digits=1) , but I
> >> don't want to read that 90 page long floating point paper
> which was
> >> referenced somewhere :)
> >
> >
> > Or you could try the much shorter R FAQ 7.31. Turns out it
> isn't weird
> > at all, if you are a computer.
>
> You're a computer! :)
>
> But yes.. the FAQ entry was where I found all.equal and the
> referenced 90-page-paper. But I didn't find out how to do a
> subset with 'somevector > 0.4'.
>
> I think I'll have to round the numbers every time now.. or
> use some other not-so-pretty workaround like 'somevector >
> 0.4 - 0.05' for 0.1-binned data.
>
> ______________________________________________
> 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.
>



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. Received on Thu 31 Mar 2011 - 13:24:46 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 Thu 31 Mar 2011 - 13:40:26 GMT.

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

list of date sections of archive