.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_stochastic_processes/plot_covariance_model_nugget.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_stochastic_processes_plot_covariance_model_nugget.py: Create a covariance model with and without a nugget effect ========================================================== .. GENERATED FROM PYTHON SOURCE LINES 7-19 This example shows the impact of a nugget effect on the covariance function of a process: - we create two covariance functions: the second one adds a nugget effect to the first one, - we draw the covariance functions. The nugget effect allows us to model a noise observed in the output values of a process. This noise may be, for example, a measurement noise from a sensor with finite precision. The noise is characterized by the scalar :math:`\varepsilon_{nugget}` which is added to the correlation function evaluated on each :math:`(\vect{s}, \vect{s})` where :math:`\vect{s} \in \cD`. See :ref:`Covariance models ` to get more details on covariance models and the introduction of a nugget factor, and in particular see equation :eq:`Css`. .. GENERATED FROM PYTHON SOURCE LINES 21-26 .. code-block:: Python import openturns as ot import openturns.viewer as otv # sphinx_gallery_thumbnail_number = 1 .. GENERATED FROM PYTHON SOURCE LINES 27-32 First we create the covariance function of a process defined on :math:`\cD \in \Rset` and with scalar outputs. We use the :class:`~openturns.SquaredExponential` with unit scale, unit amplitude. By default, the nugget factor is equal to :math:`10^{-12}` (defined through the `CovarianceModel-DefaultNuggetFactor` key in the class :class:`~openturns.ResourceMap`) which allows the regularization of the covariance matrix. We set it to zero. .. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: Python cov_model = ot.SquaredExponential() cov_model.setNuggetFactor(0.0) .. GENERATED FROM PYTHON SOURCE LINES 36-38 Then, we create a second covariance function which adds a nugget factor to the first one with. We take the nugget factor :math:`\varepsilon_{nugget} = 1`. .. GENERATED FROM PYTHON SOURCE LINES 38-42 .. code-block:: Python cov_model_with_nugget = ot.SquaredExponential() epsilon_nugget = 1 cov_model_with_nugget.setNuggetFactor(epsilon_nugget) .. GENERATED FROM PYTHON SOURCE LINES 43-44 We draw the covariance function with and without the nugget effect. .. GENERATED FROM PYTHON SOURCE LINES 44-58 .. code-block:: Python g = cov_model.draw() g.setBoundingBox(ot.Interval([-5, 0.0], [5.0, 2.0])) g.setTitle("Without nugget effect") g_nugget = cov_model_with_nugget.draw() g_nugget.setBoundingBox(ot.Interval([-5, 0.0], [5.0, 2.0])) g_nugget.setTitle("With nugget effect") grid = ot.GridLayout(1, 2) grid.setGraph(0, 0, g) grid.setGraph(0, 1, g_nugget) view = otv.View(grid) otv.View.ShowAll() .. image-sg:: /auto_stochastic_processes/images/sphx_glr_plot_covariance_model_nugget_001.svg :alt: , Without nugget effect, With nugget effect :srcset: /auto_stochastic_processes/images/sphx_glr_plot_covariance_model_nugget_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 59-60 Display all figures. .. GENERATED FROM PYTHON SOURCE LINES 60-61 .. code-block:: Python otv.View.ShowAll() .. _sphx_glr_download_auto_stochastic_processes_plot_covariance_model_nugget.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_covariance_model_nugget.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_covariance_model_nugget.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_covariance_model_nugget.zip `