.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_probabilistic_modeling/stochastic_processes/plot_create_normal_process.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_probabilistic_modeling_stochastic_processes_plot_create_normal_process.py: Create a normal process ======================= .. GENERATED FROM PYTHON SOURCE LINES 6-12 .. code-block:: default from __future__ import print_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 13-17 Create a gaussian process from a covariance model ------------------------------------------------- In this paragraph we build a gaussian process from its covariance model. .. GENERATED FROM PYTHON SOURCE LINES 20-21 We first define a covariance model : .. GENERATED FROM PYTHON SOURCE LINES 23-31 .. code-block:: default defaultDimension = 1 # Amplitude values amplitude = [1.0]*defaultDimension # Scale values scale = [1.0]*defaultDimension # Covariance model myModel = ot.AbsoluteExponential(scale, amplitude) .. GENERATED FROM PYTHON SOURCE LINES 32-33 We define a mesh, .. GENERATED FROM PYTHON SOURCE LINES 33-38 .. code-block:: default tmin = 0.0 step = 0.1 n = 11 myTimeGrid = ot.RegularGrid(tmin, step, n) .. GENERATED FROM PYTHON SOURCE LINES 39-40 and create the process : .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: default process = ot.GaussianProcess(myModel, myTimeGrid) print(process) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none GaussianProcess(trend=[x0]->[0.0], covariance=AbsoluteExponential(scale=[1], amplitude=[1])) .. GENERATED FROM PYTHON SOURCE LINES 44-45 We draw the first marginal of a sample of size 6 : .. GENERATED FROM PYTHON SOURCE LINES 45-51 .. code-block:: default sample = process.getSample(6) graph = sample.drawMarginal(0) graph.setTitle("First marginal of six realizations of the process") view = viewer.View(graph) .. image:: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_create_normal_process_001.png :alt: First marginal of six realizations of the process :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 52-57 Create a gaussian process from spectral density ----------------------------------------------- In this paragraph we build a gaussian process from its spectral density. .. GENERATED FROM PYTHON SOURCE LINES 59-60 We first define a spectral model : .. GENERATED FROM PYTHON SOURCE LINES 60-66 .. code-block:: default amplitude = [1.0, 2.0] scale = [4.0, 5.0] spatialCorrelation = ot.CorrelationMatrix(2) spatialCorrelation[0,1] = 0.8 mySpectralModel = ot.CauchyModel(scale, amplitude, spatialCorrelation) .. GENERATED FROM PYTHON SOURCE LINES 67-68 As usual we define a mesh, .. GENERATED FROM PYTHON SOURCE LINES 68-70 .. code-block:: default myTimeGrid = ot.RegularGrid(0.0, 0.1, 20) .. GENERATED FROM PYTHON SOURCE LINES 71-72 and create the process thereafter .. GENERATED FROM PYTHON SOURCE LINES 72-75 .. code-block:: default process = ot.SpectralGaussianProcess(mySpectralModel, myTimeGrid) print(process) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none SpectralGaussianProcess=SpectralGaussianProcess dimension=2 spectralModel=class=CauchyModel amplitude=[1,2] scale=[4,5] spatial correlation= [[ 1 0.8 ] [ 0.8 1 ]] maximal frequency=5 n frequency=10 .. GENERATED FROM PYTHON SOURCE LINES 76-77 Eventually we draw the first marginal of a sample of size 6 : .. GENERATED FROM PYTHON SOURCE LINES 77-82 .. code-block:: default sample = process.getSample(6) graph = sample.drawMarginal(0) graph.setTitle("First marginal of six realizations of the process") view = viewer.View(graph) .. image:: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_create_normal_process_002.png :alt: First marginal of six realizations of the process :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 83-84 Display figures .. GENERATED FROM PYTHON SOURCE LINES 84-86 .. code-block:: default plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.212 seconds) .. _sphx_glr_download_auto_probabilistic_modeling_stochastic_processes_plot_create_normal_process.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_create_normal_process.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_create_normal_process.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_