.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "advanced/mathematical_optimization/auto_examples/plot_noisy.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_advanced_mathematical_optimization_auto_examples_plot_noisy.py: Noisy optimization problem =========================== Draws a figure explaining noisy vs non-noisy optimization .. GENERATED FROM PYTHON SOURCE LINES 7-29 .. image-sg:: /advanced/mathematical_optimization/auto_examples/images/sphx_glr_plot_noisy_001.png :alt: plot noisy :srcset: /advanced/mathematical_optimization/auto_examples/images/sphx_glr_plot_noisy_001.png :class: sphx-glr-single-img .. code-block:: default import numpy as np import matplotlib.pyplot as plt 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 plt.figure(1, figsize=(3, 2.5)) plt.clf() plt.plot(x_, f(x_) + .2*np.random.normal(size=31), linewidth=2) plt.plot(x, f(x), linewidth=2) plt.ylim(ymin=-1.3) plt.axis('off') plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.027 seconds) .. _sphx_glr_download_advanced_mathematical_optimization_auto_examples_plot_noisy.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_noisy.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_noisy.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_