.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_design_of_experiments/plot_compute_ell2_error.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_auto_design_of_experiments_plot_compute_ell2_error.py: Compute the L2 error between two functions ========================================== .. GENERATED FROM PYTHON SOURCE LINES 9-10 In this example we compute the L2 error between two functions. .. GENERATED FROM PYTHON SOURCE LINES 12-15 .. code-block:: Python import openturns as ot from openturns.usecases import ishigami_function .. GENERATED FROM PYTHON SOURCE LINES 16-18 This is easy using the arithmetic operator `-` on two instances of the :class:`~openturns.Function` class. .. GENERATED FROM PYTHON SOURCE LINES 20-29 .. code-block:: Python im = ishigami_function.IshigamiModel() partOfIshigamiFunction = ot.SymbolicFunction( ["x1", "x2", "x3"], ["7 * (sin(x2))^2 + 0.1 * x3^4 * sin(x1)"] ) sampleSize = 1000 experiment = ot.MonteCarloExperiment(im.distribution, sampleSize) integration = ot.ExperimentIntegration(experiment) functionError = integration.computeL2Norm(im.model - partOfIshigamiFunction) print(functionError) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.717618] .. _sphx_glr_download_auto_design_of_experiments_plot_compute_ell2_error.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_compute_ell2_error.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_compute_ell2_error.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_compute_ell2_error.zip `