http://www-users.math.umn.edu/~arnold/disasters/disasters.html

]]>It means if you write code like `2 == sqrt(2) * sqrt(2)`

and expect the result to be true, you’re going to be very disappointed,

> 2 == sqrt(2) * sqrt(2) [1] FALSE

You’ll also be disappointed if you write code like `X * t(X)`

and expect the result to be symmetric. Or write someting like `1 - 1e-20`

and expect a result other than 1.

What it really means is that whenever you do floating point, you have to worry about loss of precision and be very careful with comparison.

As to front loading, the point of the post was to get an answer to Richard McElreath’s question. I wasn’t trying to explain floating point to the masses. I put the question in the title and then led with it. I don’t quite see how I could’ve front loaded it any more, but I’m always open to suggestions.

]]>Speakers should front load, as Dale Carnegie advised, “why you should listen to what I’m about to tell you” rather than leaving it up to listeners to stay interested long enough to wait for the punch line. Just sayin’. Or maybe I missed it, in which case I blame myself for being dumb.

]]>Helping R to be (even more) accurate ]]>

I’m currently implementing a robust mean-parameterized truncated exponential distribution in Stan, and these numeric issues are popping up all over the place. One thing I’ve found that Stan needs (had to implement it myself) is log1mexpn(x) = log(1 – exp(-x)), which has issues for *both* large and small positive values of x.

]]>I also learn (or relearn) from working through other peoples examples. The Stan case studies are one great resource, I like working through them and sometimes I realize that my approach would have been different and try to work out why our approaches differ (thought and trial and error). If my way is better then I have something that I can share, if my way is worse then I have an opportunity to learn, if they are about the same then at least I have another potential tool in my toolbox to consider another time (me learning is the most common occurrence, but starting off willing to accept any of the outcomes is my strategy).

]]>