.. 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_covariance_hmat.py:
Create a gaussian process from a cov. model using HMatrix
=========================================================
In this basic example we are going to build a gaussian process from its covariance model and using the `HMatrix` as sampling method.
.. 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 the covariance model :
.. code-block:: default
dimension = 1
amplitude = [1.0] * dimension
scale = [10] * dimension
covarianceModel = ot.AbsoluteExponential(scale, amplitude)
Define the time grid on which we want to sample the gaussian process :
define a mesh
.. code-block:: default
tmin = 0.0
step = 0.01
n = 10001
timeGrid = ot.RegularGrid(tmin, step, n)
Finally define the gaussian process :
create the process
.. code-block:: default
process = ot.GaussianProcess(covarianceModel, timeGrid)
print(process)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
GaussianProcess(trend=[x0]->[0.0], covariance=AbsoluteExponential(scale=[10], amplitude=[1]))
We set the sampling method to `HMAT`
.. code-block:: default
process.setSamplingMethod(1)
We sample the process :
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_covariance_hmat_001.png
:alt: Unnamed - 0 marginal
:class: sphx-glr-single-img
We notice here that we are able to sample the covariance model over a mesh of size `10000`, which is usually tricky on laptop. This is mainly due to the compression.
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.893 seconds)
.. _sphx_glr_download_auto_probabilistic_modeling_stochastic_processes_plot_gaussian_process_covariance_hmat.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_covariance_hmat.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_gaussian_process_covariance_hmat.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_