Grid computing

Grid computing is a simple brute-force approach. Even if you are not able to compute the whole posterior, you may be able to compute the prior and the likelihood point-wise; this is a pretty common scenario, if not the most common one. Let's assume we want to compute the posterior for a single parameter model, the grid approximation is as follows:

  1. Define a reasonable interval for the parameter (the prior should give you a hint).
  2. Place a grid of points (generally equidistant) on that interval.
  3. For each point in the grid, multiply the likelihood and the prior.

Optionally, we may normalize the computed values, that is, to divide the result at each point by the sum of all points.

The following block of code implements the grid ...

Get Bayesian Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.