2.7.4.2. Noisy optimization problemΒΆ

Draws a figure explaining noisy vs non-noisy optimization

../../../_images/sphx_glr_plot_noisy_001.png
import numpy as np
import pylab as pl
np.random.seed(0)
x = np.linspace(-5, 5, 101)
x_ = np.linspace(-5, 5, 31)
def f(x):
return -np.exp(-x**2)
# A smooth function
pl.figure(1, figsize=(3, 2.5))
pl.clf()
pl.plot(x_, f(x_) + .2*np.random.normal(size=31), linewidth=2)
pl.plot(x, f(x), linewidth=2)
pl.ylim(ymin=-1.3)
pl.axis('off')
pl.tight_layout()
pl.show()

Total running time of the script: ( 0 minutes 0.061 seconds)

Gallery generated by Sphinx-Gallery