3 % @file laplaceapprox.m
4 % @brief Laplace approximation
for multidimensional integrals.
10 % @brief Laplace approximation
for multidimensional integrals.
11 % @fn laplaceapprox(h, x0)
12 % @param h Function handle to approximate integral of.
13 % @param x0 Point
for Laplace approximation.
14 % @
return I Approximate integral value.
15 % @
return H Hessian matrix at x0.
16 % @
return logI Logarithm of integral value.
19function [I,H,logI] = laplaceapprox(h,x0)
20% I = laplaceapprox(f,x0)
21% approximates I=
int f(x)dx by Laplace approximation at x0
22% example: I = laplaceapprox(@(x) prod(x),[0.5,0.5])
23d = length(x0); % number of dimensions
25H = num_hess(@(x) log(h(x)), x0, tol);
29 H = num_hess(@(x) log(h(x)), x0, tol);
34 H = num_hess(@(x) log(h(x)), x0, tol);
38 warning('laplaceapprox.m: det(-H)<0')
40I = h(x0) * sqrt((2*pi)^d/detnH);
41logI = log(h(x0)) + (d/2)*log(2*pi) - log(detnH);