Process sample manipulationΒΆ

# sphinx_gallery_thumbnail_number = 2

The objective here is to create and manipulate a process sample. A process sample is a collection of fields which share the same mesh \mathcal{M} \in \mathbb{R}^n.

A process sample can be obtained as K realizations of a multivariate stochastic process X: \Omega \times \mathcal{D} \rightarrow \mathbb{R}^d of dimension d where \mathcal{D} \in \mathbb{R}^n, when the realizations are discretized on the same mesh \mathcal{M} of \mathcal{D}. The values (\underline{x}_0^k, \dots, \underline{x}_{N-1}^k) of the field k are defined by:

\forall i \in [0, N-1],\quad \underline{x}_i= X(\omega_k)(\underline{t}_i)

from __future__ import print_function
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)

First, define a regular 2-d mesh

discretization = [10, 5]
mesher = ot.IntervalMesher(discretization)
lowerBound = [0.0, 0.0]
upperBound = [2.0, 1.0]
interval = ot.Interval(lowerBound, upperBound)
mesh = mesher.build(interval)
mesh = ot.RegularGrid(0.0, 0.01, 100)
graph = mesh.draw()
view = viewer.View(graph)
Mesh Unnamed

Allocate a process sample from a field

field = ot.Field()
sampleSize = 10
processSample = ot.ProcessSample(sampleSize, field)
#field.draw()

Create a process sample as realizations of a process

amplitude = [1.0]
scale = [0.2]*1
myCovModel = ot.ExponentialModel(scale, amplitude)
myProcess = ot.GaussianProcess(myCovModel, mesh)
processSample = myProcess.getSample(10)
#processSample

draw the sample, without interpolation

graph = processSample.drawMarginal(0, False)
view = viewer.View(graph)
Unnamed - 0 marginal

draw the sample, with interpolation

graph = processSample.drawMarginal(0)
view = viewer.View(graph)
Unnamed - 0 marginal

Compute the mean of the process sample The result is a field

graph = processSample.computeMean().drawMarginal()
view = viewer.View(graph)
Unnamed - 0 marginal

Draw the quantile field

graph = processSample.computeQuantilePerComponent(0.9).drawMarginal(0)
view = viewer.View(graph)
Unnamed - 0 marginal

Draw the field with interpolation

graph = processSample.drawMarginal(0)
view = viewer.View(graph)
Unnamed - 0 marginal

processSample

plt.show()

Total running time of the script: ( 0 minutes 0.557 seconds)

Gallery generated by Sphinx-Gallery