Path: blob/master/notebooks/book1/04/laplace_approx_beta_binom_jax.ipynb
1192 views
Kernel: Python [conda env:py3713]
Laplace approximation ( Quadratic approximation)
In this notebook we will approximate posterior of beta-bernouli model for coin toss problem using laplace approximation method
author: @karm-patel @nipunbatra
In [1]:
In [2]:
In [3]:
Out[3]:
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
In [4]:
In [5]:
Out[5]:
Laplace approximation from scratch in JAX
As mentioned in book2 section 7.4.3, Using laplace approximation, any distribution can be approximated as normal distribution having mean and standard deviation as Where H is Hessian and is the mode
Find
No we find (_map) by minimizing negative log prior-likelhihood.
In [6]:
In [7]:
In [8]:
In [9]:
In [10]:
Out[10]:
In [11]:
Out[11]:
loc and scale of approximated normal posterior
In [12]:
Out[12]:
In [13]:
Out[13]:
True posterior and laplace approximated posterior
In [14]:
In [15]:
Out[15]:
saving image to figures/bb_laplace_latexified.pdf
Figure size: [2.7 1.5]
Grid Approximation
In [16]:
In [17]:
In [18]:
In [19]:
Out[19]:
20
In [20]:
Out[20]:
saving image to figures/bb_grid_latexified.pdf
Figure size: [2.7 1.5]
In [ ]: