In [6]:
from IPython.display import Image
Image(filename="DifficultDensities_banana_eg.png", width=350)
Out[6]:
In [8]:
def Rosenbrock_lnP(x, y, a=1.0, b=100.0):
return -( (a-x)**2 + b*(y-x**2)**2 )
In [10]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (8.0, 8.0)
xs = np.arange(-2.0, 3.0, 0.0025)
ys = np.arange(0.0, 5.0, 0.0025)
zs = np.array([Rosenbrock_lnP(xs,y) for y in ys])
plt.contour(xs, ys, -2.0*zs, levels=[2.3, 6.18, 11.8]);
In [50]:
xs = np.arange(-2.0, 3.0, 0.0025)
lnys = np.arange(-3.0, 1.6, 0.0025)
zs = np.array([Rosenbrock_lnP(xs,y) for y in np.exp(lnys)])
plt.contour(xs, lnys, -2.0*zs, levels=[2.3, 6.18, 11.8]);
In [29]:
def eggbox_lnP(x, y):
return (2.0 + np.cos(0.5*x)*np.cos(0.5*y))**3
xs = np.arange(0.0, 30.0, 0.1)
ys = np.arange(0.0, 30.0, 0.1)
zs = np.array([eggbox_lnP(xs,y) for y in ys])
plt.contour(xs, ys, -2.0*(zs-np.max(zs)), levels=[2.3, 6.18, 11.8]);
In [31]:
Image(filename="DifficultDensities_multimodes_eg.png", width=350)
Out[31]:
Another nice density, not listed on Wikipedia, is the spherical shell: $\ln P = -\frac{1}{2\sigma^2}\left(\sqrt{x^2+y^2}-1\right)^2$, for $\sigma \sim 0.1$. This one lends itself to a simple re-parametrization, however!