.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_meta_modeling/kriging_metamodel/plot_draw_covariance_models.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_meta_modeling_kriging_metamodel_plot_draw_covariance_models.py: Kriging : draw covariance models ================================ .. GENERATED FROM PYTHON SOURCE LINES 5-11 .. code-block:: Python import openturns as ot import openturns.viewer as otv from matplotlib import pylab as plt import pylab as pl .. GENERATED FROM PYTHON SOURCE LINES 12-21 Abstract -------- Gaussian processes are a common fixture in `UQ`. They are defined by their covariance function and the library implements several of them. In this example we plot covariance functions and modify their parameters for two families of models: the generalized exponential model and the Matérn models. For visualization sake, we limit ourselves to the dimension 1. .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. code-block:: Python dimension = 1 .. GENERATED FROM PYTHON SOURCE LINES 24-25 We set the lower bound to zero for stationary kernels .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: Python ot.ResourceMap.SetAsScalar("CovarianceModel-DefaultTMin", 0.0) .. GENERATED FROM PYTHON SOURCE LINES 29-36 The generalized exponential model --------------------------------- The :class:`~openturns.GeneralizedExponential` class implements a generalized exponential with a parameter :math:`p < 0 \leq 2` exponent. The case :math:`p=1` is the standard exponential model while :math:`p=2` is the squared exponential. .. GENERATED FROM PYTHON SOURCE LINES 38-44 Various parameters p and a fixed correlation length of 0.1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In this part we set the correlation length to :math:`\theta = 0.1` and study three different models with parameters :math:`p=0.25`, :math:`p=1` and :math:`p=2` and trajectories from Gaussian processes based on these models. .. GENERATED FROM PYTHON SOURCE LINES 46-47 We define the :math:`p = 0.25` generalized exponential model : .. GENERATED FROM PYTHON SOURCE LINES 47-49 .. code-block:: Python covarianceModel = ot.GeneralizedExponential([0.1], 0.25) .. GENERATED FROM PYTHON SOURCE LINES 50-51 We define the :math:`p = 1` generalized exponential model : .. GENERATED FROM PYTHON SOURCE LINES 51-53 .. code-block:: Python covarianceModel2 = ot.GeneralizedExponential([0.1], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 54-55 We define the :math:`p = 2` generalized exponential model : .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: Python covarianceModel3 = ot.GeneralizedExponential([0.1], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 58-59 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 59-68 .. code-block:: Python graphModel = covarianceModel.draw() graphModel.add(covarianceModel2.draw()) graphModel.add(covarianceModel3.draw()) graphModel.setColors(["green", "orange", "blue"]) graphModel.setXTitle(r"$\tau = \|s-t\|$") graphModel.setYTitle(r"$C(\tau)$") graphModel.setLegends([r"$p = 0.25$", r"$p = 1$", r"$p = 2$"]) .. GENERATED FROM PYTHON SOURCE LINES 69-72 For each covariance model we build a Gaussian process and generate a random trajectory of on :math:`[-1,1]`. We first build a discretization of this interval with a regular grid with step 0.01. .. GENERATED FROM PYTHON SOURCE LINES 72-78 .. code-block:: Python xmin = -1.0 step = 0.01 n = 200 grid1D = ot.RegularGrid(xmin, step, n + 1) nbTrajectories = 1 .. GENERATED FROM PYTHON SOURCE LINES 79-80 We define the first Gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 80-83 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 84-85 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 85-88 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 89-90 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 90-93 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 94-95 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 95-104 .. code-block:: Python graphTraj = sample.drawMarginal(0) graphTraj.add(sample2.drawMarginal(0)) graphTraj.add(sample3.drawMarginal(0)) graphTraj.setXTitle(r"$x$") graphTraj.setYTitle(r"$GP_{\nu}(x)$") graphTraj.setTitle("Random realization from the covariance model") graphTraj.setColors(["green", "orange", "blue"]) graphTraj.setLegends([r"$p = 0.25$", r"$p = 1$", r"$p = 2$"]) .. GENERATED FROM PYTHON SOURCE LINES 105-106 We present each covariance model and the corresponding trajectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 106-113 .. code-block:: Python fig = pl.figure(figsize=(12, 4)) ax_pdf = fig.add_subplot(1, 2, 1) _ = otv.View(graphModel, figure=fig, axes=[ax_pdf]) ax_cdf = fig.add_subplot(1, 2, 2) _ = otv.View(graphTraj, figure=fig, axes=[ax_cdf]) _ = fig.suptitle(r"Generalized Exponential Model : influence of the p parameter") .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_001.png :alt: Generalized Exponential Model : influence of the p parameter :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 114-116 The blue trajectory corresponding to the parameter :math:`p=2` is smooth as expected as compared with the :math:`p=0.25` process which is less regular. .. GENERATED FROM PYTHON SOURCE LINES 119-125 The exponential model (:math:`p=1`) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In the case of the exponential model (:math:`p=1`) we show the influence of the correlation length on the trajectories. .. GENERATED FROM PYTHON SOURCE LINES 127-128 with correlation length :math:`\theta = 0.01` : .. GENERATED FROM PYTHON SOURCE LINES 128-130 .. code-block:: Python covarianceModel = ot.GeneralizedExponential([0.01], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 131-132 with correlation length :math:`\theta = 0.1` : .. GENERATED FROM PYTHON SOURCE LINES 132-134 .. code-block:: Python covarianceModel2 = ot.GeneralizedExponential([0.1], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 135-136 with correlation length :math:`\theta = 1.0` .. GENERATED FROM PYTHON SOURCE LINES 136-138 .. code-block:: Python covarianceModel3 = ot.GeneralizedExponential([1.0], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 139-140 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 140-149 .. code-block:: Python graphModel = covarianceModel.draw() graphModel.add(covarianceModel2.draw()) graphModel.add(covarianceModel3.draw()) graphModel.setColors(["green", "orange", "blue"]) graphModel.setXTitle(r"$\tau = \|s-t\|$") graphModel.setYTitle(r"$C(\tau)$") graphModel.setLegends([r"$\theta = 0.01$", r"$\theta = 0.1$", r"$\theta = 1$"]) .. GENERATED FROM PYTHON SOURCE LINES 150-153 For each covariance model we build a Gaussian process and generate a random trajectory of on :math:`[-1,1]`. We first build a discretization of this interval with a regular grid with step 0.01. .. GENERATED FROM PYTHON SOURCE LINES 153-159 .. code-block:: Python xmin = -1.0 step = 0.01 n = 200 grid1D = ot.RegularGrid(xmin, step, n + 1) nbTrajectories = 1 .. GENERATED FROM PYTHON SOURCE LINES 160-161 We define the first Gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 161-164 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 165-166 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 166-169 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 170-171 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 171-174 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 175-176 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 176-185 .. code-block:: Python graphTraj = sample.drawMarginal(0) graphTraj.add(sample2.drawMarginal(0)) graphTraj.add(sample3.drawMarginal(0)) graphTraj.setXTitle(r"$x$") graphTraj.setYTitle(r"$GP_{\theta}(x)$") graphTraj.setTitle("Random realization from the covariance model") graphTraj.setColors(["green", "orange", "blue"]) graphTraj.setLegends([r"$\theta = 0.01$", r"$\theta = 0.1$", r"$\theta = 1$"]) .. GENERATED FROM PYTHON SOURCE LINES 186-187 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 187-194 .. code-block:: Python fig = pl.figure(figsize=(12, 4)) ax_pdf = fig.add_subplot(1, 2, 1) _ = otv.View(graphModel, figure=fig, axes=[ax_pdf]) ax_cdf = fig.add_subplot(1, 2, 2) _ = otv.View(graphTraj, figure=fig, axes=[ax_cdf]) _ = fig.suptitle(r"Exponential Model : influence of correlation length $\theta$") .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_002.png :alt: Exponential Model : influence of correlation length $\theta$ :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 195-196 We observe a smoother trajectory with a high correlation value. .. GENERATED FROM PYTHON SOURCE LINES 199-206 The squared exponential (:math:`p=2`) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In the case of the squared exponential model (:math:`p=2`) we show the influence of the correlation length on the trajectories. .. GENERATED FROM PYTHON SOURCE LINES 208-209 with correlation length :math:`\theta = 0.01` : .. GENERATED FROM PYTHON SOURCE LINES 209-211 .. code-block:: Python covarianceModel = ot.GeneralizedExponential([0.01], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 212-213 with correlation length :math:`\theta = 0.1` : .. GENERATED FROM PYTHON SOURCE LINES 213-215 .. code-block:: Python covarianceModel2 = ot.GeneralizedExponential([0.1], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 216-217 with correlation length :math:`\theta = 1.0` .. GENERATED FROM PYTHON SOURCE LINES 217-219 .. code-block:: Python covarianceModel3 = ot.GeneralizedExponential([1.0], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 220-221 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 221-230 .. code-block:: Python graphModel = covarianceModel.draw() graphModel.add(covarianceModel2.draw()) graphModel.add(covarianceModel3.draw()) graphModel.setColors(["green", "orange", "blue"]) graphModel.setXTitle(r"$\tau = \|s-t\|$") graphModel.setYTitle(r"$C(\tau)$") graphModel.setLegends([r"$\theta = 0.01$", r"$\theta = 0.1$", r"$\theta = 1$"]) .. GENERATED FROM PYTHON SOURCE LINES 231-234 For each covariance model we build a Gaussian process and generate a random trajectory of on :math:`[-1,1]`. We first build a discretization of this interval with a regular grid with step 0.01. .. GENERATED FROM PYTHON SOURCE LINES 234-240 .. code-block:: Python xmin = -1.0 step = 0.01 n = 200 grid1D = ot.RegularGrid(xmin, step, n + 1) nbTrajectories = 1 .. GENERATED FROM PYTHON SOURCE LINES 241-242 We define the first Gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 242-245 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 246-247 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 247-250 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 251-252 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 252-255 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 256-257 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 257-266 .. code-block:: Python graphTraj = sample.drawMarginal(0) graphTraj.add(sample2.drawMarginal(0)) graphTraj.add(sample3.drawMarginal(0)) graphTraj.setXTitle(r"$x$") graphTraj.setYTitle(r"$GP_{\theta}(x)$") graphTraj.setTitle("Random realization from the covariance model") graphTraj.setColors(["green", "orange", "blue"]) graphTraj.setLegends([r"$\theta = 0.01$", r"$\theta = 0.1$", r"$\theta = 1$"]) .. GENERATED FROM PYTHON SOURCE LINES 267-268 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 268-278 .. code-block:: Python fig = pl.figure(figsize=(12, 4)) ax_pdf = fig.add_subplot(1, 2, 1) _ = otv.View(graphModel, figure=fig, axes=[ax_pdf]) ax_cdf = fig.add_subplot(1, 2, 2) _ = otv.View(graphTraj, figure=fig, axes=[ax_cdf]) _ = fig.suptitle( r"Squared exponential model : influence of correlation length $\theta$" ) .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_003.png :alt: Squared exponential model : influence of correlation length $\theta$ :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 279-281 Except for very small values of the correlation length, trajectories are usually smooth. It is the main effect of the squared exponential model which leads to smooth processes. .. GENERATED FROM PYTHON SOURCE LINES 284-290 The Matérn covariance model --------------------------- The :class:`~openturns.MaternModel` class implements the Matern model of parameter :math:`\nu`. This parameter controls the smoothness of the process : for any :math:`\nu = n + \frac{1}{2}` the process is :math:`n` times continuously differentiable. .. GENERATED FROM PYTHON SOURCE LINES 292-299 Influence of the regularity ^^^^^^^^^^^^^^^^^^^^^^^^^^^ In this paragraph we represent three models with different regularity and generate the corresponding random trajectories. We shall use :math:`\nu = 0.5`, :math:`\nu = 1.5` and :math:`\nu = 2.5` and observe the regularity. .. GENERATED FROM PYTHON SOURCE LINES 301-302 We define the :math:`\nu = 0.5` Matern model : .. GENERATED FROM PYTHON SOURCE LINES 302-304 .. code-block:: Python covarianceModel = ot.MaternModel([1.0], 0.5) .. GENERATED FROM PYTHON SOURCE LINES 305-306 We define the :math:`\nu = 1.5` Matern model : .. GENERATED FROM PYTHON SOURCE LINES 306-308 .. code-block:: Python covarianceModel2 = ot.MaternModel([1.0], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 309-310 We define the :math:`\nu = 2.5` Matern model : .. GENERATED FROM PYTHON SOURCE LINES 310-312 .. code-block:: Python covarianceModel3 = ot.MaternModel([1.0], 2.5) .. GENERATED FROM PYTHON SOURCE LINES 313-314 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 314-323 .. code-block:: Python graphModel = covarianceModel.draw() graphModel.add(covarianceModel2.draw()) graphModel.add(covarianceModel3.draw()) graphModel.setColors(["green", "orange", "blue"]) graphModel.setXTitle(r"$\tau = \|s-t\|$") graphModel.setYTitle(r"$C(\tau)$") graphModel.setLegends([r"$\nu = 1/2$", r"$\nu = 3/2$", r"$\nu = 5/2$"]) .. GENERATED FROM PYTHON SOURCE LINES 324-327 For each covariance model we build a Gaussian process and generate a random trajectory of on :math:`[-1,1]`. We first build a discretization of this interval with a regular grid with step 0.001. .. GENERATED FROM PYTHON SOURCE LINES 327-333 .. code-block:: Python xmin = -5.0 step = 0.01 n = 1000 grid1D = ot.RegularGrid(xmin, step, n + 1) nbTrajectories = 1 .. GENERATED FROM PYTHON SOURCE LINES 334-335 We define the first Gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 335-338 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 339-340 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 340-343 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 344-345 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 345-348 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 349-350 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 350-359 .. code-block:: Python graphTraj = sample.drawMarginal(0) graphTraj.add(sample2.drawMarginal(0)) graphTraj.add(sample3.drawMarginal(0)) graphTraj.setXTitle(r"$x$") graphTraj.setYTitle(r"$GP_{\nu}(x)$") graphTraj.setTitle("Random realization from the covariance model") graphTraj.setColors(["green", "orange", "blue"]) graphTraj.setLegends([r"$\nu = 1/2$", r"$\nu = 3/2$", r"$\nu = 5/2$"]) .. GENERATED FROM PYTHON SOURCE LINES 360-361 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 361-368 .. code-block:: Python fig = pl.figure(figsize=(12, 4)) ax_pdf = fig.add_subplot(1, 2, 1) _ = otv.View(graphModel, figure=fig, axes=[ax_pdf]) ax_cdf = fig.add_subplot(1, 2, 2) _ = otv.View(graphTraj, figure=fig, axes=[ax_cdf]) _ = fig.suptitle(r"Matern model : influence of the regularity $\nu$ parameter") .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_004.png :alt: Matern model : influence of the regularity $\nu$ parameter :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 369-371 The red trajectory is the least regular (:math:`nu = 0.5`) as it is only continuous. We see that the the blue trajectory is more smooth as expected. .. GENERATED FROM PYTHON SOURCE LINES 374-382 Variation of the correlation length ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In this paragraph we fix the regularity by choosing :math:`\nu = 1.5` so we expect a continuously differentiable realization. We then use three different correlation lengths :math:`\theta = 0.01`, :math:`\theta = 0.1` and :math:`\theta = 1.0` and observe the impact on realizations of Gaussian processes based on these covariance models. .. GENERATED FROM PYTHON SOURCE LINES 384-385 We define the Matern model with :math:`\theta = 0.01` : .. GENERATED FROM PYTHON SOURCE LINES 385-387 .. code-block:: Python covarianceModel = ot.MaternModel([0.01], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 388-389 We define the Matern model with :math:`\theta = 0.1` : .. GENERATED FROM PYTHON SOURCE LINES 389-391 .. code-block:: Python covarianceModel2 = ot.MaternModel([0.1], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 392-393 We define the Matern model with :math:`\theta = 1.0` : .. GENERATED FROM PYTHON SOURCE LINES 393-395 .. code-block:: Python covarianceModel3 = ot.MaternModel([1.0], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 396-397 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 397-406 .. code-block:: Python graphModel = covarianceModel.draw() graphModel.add(covarianceModel2.draw()) graphModel.add(covarianceModel3.draw()) graphModel.setColors(["green", "orange", "blue"]) graphModel.setXTitle(r"$\tau = \|s-t\|$") graphModel.setYTitle(r"$C(\tau)$") graphModel.setTitle("Matern covariance model with \nu = 3/2") graphModel.setLegends([r"$\theta = 0.01$", r"$\theta = 0.1$", r"$\theta = 1.0$"]) .. GENERATED FROM PYTHON SOURCE LINES 407-410 For each covariance model we build a Gaussian process and generate a random trajectory of on :math:`[-1,1]`. We build a discretization of this interval with a regular grid with step 0.01. .. GENERATED FROM PYTHON SOURCE LINES 410-416 .. code-block:: Python xmin = -1.0 step = 0.01 n = 200 grid1D = ot.RegularGrid(xmin, step, n + 1) nbTrajectories = 1 .. GENERATED FROM PYTHON SOURCE LINES 417-418 We define the first Gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 418-421 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 422-423 then the second process : .. GENERATED FROM PYTHON SOURCE LINES 423-426 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 427-428 and the third one : .. GENERATED FROM PYTHON SOURCE LINES 428-431 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 432-433 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 433-441 .. code-block:: Python graphTraj = sample.drawMarginal(0) graphTraj.add(sample2.drawMarginal(0)) graphTraj.add(sample3.drawMarginal(0)) graphTraj.setXTitle(r"$x$") graphTraj.setYTitle(r"$GP_{\theta}(x)$") graphTraj.setColors(["green", "orange", "blue"]) graphTraj.setLegends([r"$\theta = 0.01$", r"$\theta = 0.1$", r"$\theta = 1.0$"]) .. GENERATED FROM PYTHON SOURCE LINES 442-443 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 443-450 .. code-block:: Python fig = pl.figure(figsize=(12, 4)) ax_pdf = fig.add_subplot(1, 2, 1) _ = otv.View(graphModel, figure=fig, axes=[ax_pdf]) ax_cdf = fig.add_subplot(1, 2, 2) _ = otv.View(graphTraj, figure=fig, axes=[ax_cdf]) _ = fig.suptitle("The Matern model : variation of the correlation length") .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_005.png :alt: The Matern model : variation of the correlation length :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_draw_covariance_models_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 451-453 From the previous figure we see that the trajectory of the Gaussian process is smoother with large correlation length. .. GENERATED FROM PYTHON SOURCE LINES 455-456 Display figures .. GENERATED FROM PYTHON SOURCE LINES 456-458 .. code-block:: Python plt.show() .. GENERATED FROM PYTHON SOURCE LINES 459-460 Reset default settings .. GENERATED FROM PYTHON SOURCE LINES 460-461 .. code-block:: Python ot.ResourceMap.Reload() .. _sphx_glr_download_auto_meta_modeling_kriging_metamodel_plot_draw_covariance_models.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_draw_covariance_models.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_draw_covariance_models.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_draw_covariance_models.zip `