.. 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_add_trend.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_add_trend.py: Add a trend to a process ======================== .. GENERATED FROM PYTHON SOURCE LINES 6-13 In this example we are going to add a trend to a process. The TrendTransform class enables to create a new process Y from a process X (no hypothesis on X needed): .. math:: Y(\omega, t) = X(\omega, t) + f(t) .. GENERATED FROM PYTHON SOURCE LINES 15-21 .. code-block:: default import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt import math as m ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 22-23 Create a process .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: default grid = ot.RegularGrid(0.0, 0.1, 10) amplitude = [5.0] scale = [0.2] covModel = ot.ExponentialModel(scale, amplitude) X = ot.GaussianProcess(covModel, grid) .. GENERATED FROM PYTHON SOURCE LINES 30-31 Draw a sample .. GENERATED FROM PYTHON SOURCE LINES 31-36 .. code-block:: default sample = X.getSample(6) sample.setName('X') graph = sample.drawMarginal(0) view = viewer.View(graph) .. image-sg:: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_add_trend_001.png :alt: X - 0 marginal :srcset: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_add_trend_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 Define a trend function .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: default f = ot.SymbolicFunction(['t'], ['30*t']) fTrend = ot.TrendTransform(f, grid) .. GENERATED FROM PYTHON SOURCE LINES 42-43 Add it to the process .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: default Y = ot.CompositeProcess(fTrend, X) Y.setName('Y') .. GENERATED FROM PYTHON SOURCE LINES 47-48 Draw a sample .. GENERATED FROM PYTHON SOURCE LINES 48-53 .. code-block:: default sample = Y.getSample(6) sample.setName('Y') graph = sample.drawMarginal(0) view = viewer.View(graph) plt.show() .. image-sg:: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_add_trend_002.png :alt: Y - 0 marginal :srcset: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_add_trend_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.140 seconds) .. _sphx_glr_download_auto_probabilistic_modeling_stochastic_processes_plot_add_trend.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_add_trend.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_add_trend.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_