.. 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_gaussian_process_spectral.py:
Create a gaussian process from spectral density
===============================================
In this example we are going to build a gaussian process from its spectral density.
.. 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)
define a spectral model
.. 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)
define a mesh
.. code-block:: default
myTimeGrid = ot.RegularGrid(0.0, 0.1, 20)
create the process
.. 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
draw a sample
.. code-block:: default
sample = process.getSample(6)
graph = sample.drawMarginal(0)
view = viewer.View(graph)
plt.show()
.. image:: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_gaussian_process_spectral_001.png
:alt: Unnamed - 0 marginal
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.077 seconds)
.. _sphx_glr_download_auto_probabilistic_modeling_stochastic_processes_plot_gaussian_process_spectral.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_gaussian_process_spectral.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_gaussian_process_spectral.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_