.. 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-10 .. 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 11-20 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 should depict covariance functions and play with parameters for two families of models: the generalized exponential model and the Matern models. For visualization sake we should limit ourselves to the dimension 1. .. GENERATED FROM PYTHON SOURCE LINES 20-22 .. code-block:: Python dimension = 1 .. GENERATED FROM PYTHON SOURCE LINES 23-24 We set the lower bound to zero for stationary kernels .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: Python ot.ResourceMap.SetAsScalar("CovarianceModel-DefaultTMin", 0.0) .. GENERATED FROM PYTHON SOURCE LINES 28-35 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 37-43 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 45-46 We define the :math:`p = 0.25` generalized exponential model : .. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: Python covarianceModel = ot.GeneralizedExponential([0.1], 0.25) .. GENERATED FROM PYTHON SOURCE LINES 49-50 We define the :math:`p = 1` generalized exponential model : .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: Python covarianceModel2 = ot.GeneralizedExponential([0.1], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 53-54 We define the :math:`p = 2` generalized exponential model : .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: Python covarianceModel3 = ot.GeneralizedExponential([0.1], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 57-58 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 58-67 .. 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 68-71 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 71-77 .. 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 78-79 We define the first gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 79-82 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 83-84 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 84-87 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 88-89 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 89-92 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 93-94 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 94-103 .. 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 104-105 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 105-112 .. 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 113-115 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 118-124 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 126-127 with correlation length :math:`\theta = 0.01` : .. GENERATED FROM PYTHON SOURCE LINES 127-129 .. code-block:: Python covarianceModel = ot.GeneralizedExponential([0.01], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 130-131 with correlation length :math:`\theta = 0.1` : .. GENERATED FROM PYTHON SOURCE LINES 131-133 .. code-block:: Python covarianceModel2 = ot.GeneralizedExponential([0.1], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 134-135 with correlation length :math:`\theta = 1.0` .. GENERATED FROM PYTHON SOURCE LINES 135-137 .. code-block:: Python covarianceModel3 = ot.GeneralizedExponential([1.0], 1.0) .. GENERATED FROM PYTHON SOURCE LINES 138-139 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 139-148 .. 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 149-152 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 152-158 .. 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 159-160 We define the first gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 160-163 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 164-165 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 165-168 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 169-170 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 170-173 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 174-175 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 175-184 .. 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 185-186 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 186-193 .. 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 194-195 We observe a smoother trajectory with a high correlation value. .. GENERATED FROM PYTHON SOURCE LINES 198-205 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 207-208 with correlation length :math:`\theta = 0.01` : .. GENERATED FROM PYTHON SOURCE LINES 208-210 .. code-block:: Python covarianceModel = ot.GeneralizedExponential([0.01], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 211-212 with correlation length :math:`\theta = 0.1` : .. GENERATED FROM PYTHON SOURCE LINES 212-214 .. code-block:: Python covarianceModel2 = ot.GeneralizedExponential([0.1], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 215-216 with correlation length :math:`\theta = 1.0` .. GENERATED FROM PYTHON SOURCE LINES 216-218 .. code-block:: Python covarianceModel3 = ot.GeneralizedExponential([1.0], 2.0) .. GENERATED FROM PYTHON SOURCE LINES 219-220 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 220-229 .. 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 230-233 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 233-239 .. 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 240-241 We define the first gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 241-244 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 245-246 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 246-249 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 250-251 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 251-254 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 255-256 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 256-265 .. 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 266-267 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 267-277 .. 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 278-280 Execpt 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 process. .. GENERATED FROM PYTHON SOURCE LINES 283-289 The Matern 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 291-298 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 300-301 We define the :math:`\nu = 0.5` Matern model : .. GENERATED FROM PYTHON SOURCE LINES 301-303 .. code-block:: Python covarianceModel = ot.MaternModel([1.0], 0.5) .. GENERATED FROM PYTHON SOURCE LINES 304-305 We define the :math:`\nu = 1.5` Matern model : .. GENERATED FROM PYTHON SOURCE LINES 305-307 .. code-block:: Python covarianceModel2 = ot.MaternModel([1.0], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 308-309 We define the :math:`\nu = 2.5` Matern model : .. GENERATED FROM PYTHON SOURCE LINES 309-311 .. code-block:: Python covarianceModel3 = ot.MaternModel([1.0], 2.5) .. GENERATED FROM PYTHON SOURCE LINES 312-313 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 313-322 .. 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 323-326 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 326-332 .. 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 333-334 We define the first gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 334-337 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 338-339 then the second one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 339-342 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 343-344 and finally the third one and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 344-347 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 348-349 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 349-358 .. 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 359-360 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 360-367 .. 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 368-370 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 373-381 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 383-384 We define the Matern model with :math:`\theta = 0.01` : .. GENERATED FROM PYTHON SOURCE LINES 384-386 .. code-block:: Python covarianceModel = ot.MaternModel([0.01], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 387-388 We define the Matern model with :math:`\theta = 0.1` : .. GENERATED FROM PYTHON SOURCE LINES 388-390 .. code-block:: Python covarianceModel2 = ot.MaternModel([0.1], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 391-392 We define the Matern model with :math:`\theta = 1.0` : .. GENERATED FROM PYTHON SOURCE LINES 392-394 .. code-block:: Python covarianceModel3 = ot.MaternModel([1.0], 1.5) .. GENERATED FROM PYTHON SOURCE LINES 395-396 We draw the covariance models : .. GENERATED FROM PYTHON SOURCE LINES 396-405 .. 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 406-409 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 409-415 .. 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 416-417 We define the first gaussian process and its trajectory : .. GENERATED FROM PYTHON SOURCE LINES 417-420 .. code-block:: Python process = ot.GaussianProcess(covarianceModel, grid1D) sample = process.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 421-422 then the second process : .. GENERATED FROM PYTHON SOURCE LINES 422-425 .. code-block:: Python process2 = ot.GaussianProcess(covarianceModel2, grid1D) sample2 = process2.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 426-427 and the third one : .. GENERATED FROM PYTHON SOURCE LINES 427-430 .. code-block:: Python process3 = ot.GaussianProcess(covarianceModel3, grid1D) sample3 = process3.getSample(nbTrajectories) .. GENERATED FROM PYTHON SOURCE LINES 431-432 We draw the trajectories : .. GENERATED FROM PYTHON SOURCE LINES 432-440 .. 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 441-442 We present each covariance model and the corresponding tracjectory side by side. .. GENERATED FROM PYTHON SOURCE LINES 442-449 .. 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 450-452 From the previous figure we see that the trajectory of the gaussian process is smoother with large correlation length. .. GENERATED FROM PYTHON SOURCE LINES 454-455 Display figures .. GENERATED FROM PYTHON SOURCE LINES 455-457 .. code-block:: Python plt.show() .. GENERATED FROM PYTHON SOURCE LINES 458-459 Reset default settings .. GENERATED FROM PYTHON SOURCE LINES 459-460 .. 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 `