Bayesian Core and loose logs

Jean-Michel (aka Jean-Claude!) Marin came for a few days so that we could make late progress on the revision of our book Bayesian Core towards an Use R! version. In one of the R programs in the mixture chapter, we were getting improbable answers, until we found an R mistake in the shape of

 > sum(c(1,2,3,log=TRUE))
 [1] 7
 > sum(c(1,2,3),log=TRUE)
 [1] 7
 

which was not detected by the compiler… There are surely plenty of good reasons for this to happen and it did not take long to fix the bug, still… annoying!

3 Responses to “Bayesian Core and loose logs”

  1. [...] not enjoying the optimal environment of CiRM, we are making good progress on the revision (or the R vision) of Bayesian Core. In the past two days, we went over Chapters 1 (Introduction), 2 [...]

  2. This feature of R drives me up the walls! I think it will convert almost any type to any other without so much as a warning. Which of those lines is the intended one?

    • Actually none of those was intended! We had a sum(dnorm(x,log=TRUE)) than got written sum(dnorm(x),log=TRUE) by mistake and we were none the wiser after running the code (except that it did not look plausible!)…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 667 other followers