File: plot_karhunenloeve_validation.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 (65 lines) | stat: -rw-r--r-- 1,550 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
54
55
56
57
58
59
60
61
62
63
64
65
"""
Validation of a Karhunen-Loeve decomposition
============================================
"""

# %%
#
# In this example we are going to assess a Karhunen-Loeve decomposition
#

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

# %%
# Create a Gaussian process.
numberOfVertices = 20
interval = ot.Interval(-1.0, 1.0)
mesh = ot.IntervalMesher([numberOfVertices - 1]).build(interval)
covariance = ot.SquaredExponential()
process = ot.GaussianProcess(covariance, mesh)

# %%
# Decompose it using KL-SVD.
sampleSize = 100
processSample = process.getSample(sampleSize)
threshold = 1.0e-7
algo = ot.KarhunenLoeveSVDAlgorithm(processSample, threshold)
algo.run()
klresult = algo.getResult()

# %%
# Instantiate the validation service.
validation = ot.KarhunenLoeveValidation(processSample, klresult)

# %%
# Plot the residual field.
residualProcessSample = validation.computeResidual()
view = otv.View(residualProcessSample.drawMarginal(0))

# %%
# Plot the residual mean field.
residualMean = validation.computeResidualMean()
view = otv.View(residualMean.drawMarginal(0))

# %%
# Plot the residual standard deviation field.
residualSigmaField = validation.computeResidualStandardDeviation()
view = otv.View(residualSigmaField.drawMarginal(0))

# %%
# Build the validation graph.
view = otv.View(validation.drawValidation())

# %%
# Build the weight graph.
view = otv.View(validation.drawObservationWeight(0))

# %%
# Build the quality graph.
view = otv.View(validation.drawObservationQuality())

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