File: plot_add_trend.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (53 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Add a trend to a process
========================
"""

# %%
# In this example we are going to add a trend to a process.
#
# The :class:`~openturns.TrendTransform` class enables to create a new process :math:`Y` from a process :math:`X` (no hypothesis on :math:`X` needed):
#
# .. math::
#    Y(\omega, t) = X(\omega, t) + f(t)
#

# %%
import openturns as ot
import openturns.viewer as otv

# %%
# Create a process
grid = ot.RegularGrid(0.0, 0.1, 10)
amplitude = [5.0]
scale = [0.2]
covModel = ot.ExponentialModel(scale, amplitude)
X = ot.GaussianProcess(covModel, grid)

# %%
# Draw a sample
sample = X.getSample(6)
sample.setName("X")
graph = sample.drawMarginal(0)
view = otv.View(graph)

# %%
# Define a trend function
f = ot.SymbolicFunction(["t"], ["30*t"])
fTrend = ot.TrendTransform(f, grid)

# %%
# Add it to the process
Y = ot.CompositeProcess(fTrend, X)
Y.setName("Y")

# %%
# Draw a sample
sample = Y.getSample(6)
sample.setName("Y")
graph = sample.drawMarginal(0)
view = otv.View(graph)

# %%
# Display all figures
otv.View.ShowAll()