2 min read

Bayesian Surprise — the Shiny app

I wrote a while back about a toy case of the Bayesian surprise problem: what does Bayes Theorem tell you to believe when you get really surprising data. The one-dimensional case is a nice math-stat problem, if you like that sort of thing, but maybe you’d rather have the calculations done for you.

Here’s an app

The mathematical setup is that you have a prior distribution for a location parameter θ centered at zero, and you see a data point x that’s a long way from zero. If π(θ) and f(xθ) are the prior and likelihood, the posterior is proportional to π(θ)f(xθ).

When the prior is heavy-tailed and the data distribution isn’t, you’re willing to believe θ can be weird, so a very large x means your posterior for θ will be near x. When the data distribution is heavy-tailed and the prior isn’t, you’re willing to believe x can be a long way from θ, but not that θ can be a long way from zero, so the prior ends up pretty much like the posterior – you ‘reject’ the data.

The details, though, depend on how heavy-tailed things are, and the app lets you play around with a range of possibilities. Laplace–Laplace and t30t30 and t30–Normal might be interesting.

The code is here