Process sample manipulationΒΆ

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)

[1]:
from __future__ import print_function
import openturns as ot
import math as m
[2]:
# 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)
mesh.draw()
[2]:
../../_images/examples_probabilistic_modeling_processsample_manipulation_3_0.png
[3]:
# Allocate a process sample from a field
field = ot.Field()
sampleSize = 10
processSample = ot.ProcessSample(sampleSize, field)
#field.draw()
[15]:
# 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
[15]:
ty0y0...y0y0y0
00.00.18204541662690635-1.9381887884569047...-0.17827621751302086-0.82258064456059420.7555020790891768
10.010.31693036986975576-1.6727632838457833...-0.6557971110034336-1.31439231624689780.7809459682373394
20.02-0.44012297353381524-1.8623743139269542...-0.6239095486778223-0.9595650766737920.740321342937527
...
970.97-0.63483326484370640.19979696937503139...0.50995184823937060.8228505966698729-1.3885352250532688
980.98-0.830884927448569-0.07076214982000062...0.176797179501553051.1805712215667847-1.559283525482597
990.99-0.7149431051217253-0.15180096995420744...0.138472510253625970.7868992309515256-1.26374605653812
[16]:
# draw the sample, without interpolation
processSample.drawMarginal(0, False)
[16]:
../../_images/examples_probabilistic_modeling_processsample_manipulation_6_0.png
[6]:
# draw the sample, with interpolation
processSample.drawMarginal(0)
[6]:
../../_images/examples_probabilistic_modeling_processsample_manipulation_7_0.png
[25]:
# Compute the  mean of the process sample
# The result is a field
processSample.computeMean().drawMarginal()
[25]:
ty0
00.0-0.2943685746826114
10.01-0.3836675736212855
20.02-0.4280622850739695
30.03-0.38786041728633364
40.04-0.37331752910520494
50.05-0.5147909233972611
60.06-0.4990751669835663
70.07-0.4844038072635097
80.08-0.44069316329972524
90.09-0.24562945712217443
100.1-0.4360868114431804
110.11-0.5328131982827301
120.12-0.4530084660381663
130.13-0.469488376730809
140.14-0.4099617571583579
150.15-0.41990258383255175
160.16-0.291982250584867
170.17-0.3472438491341311
180.18-0.4307719777025618
190.19-0.4828868416664276
200.2-0.5009938406556245
210.21-0.5287747437704691
220.22-0.5957688046485139
230.23-0.40890131390074846
240.24-0.43919452174339774
250.25-0.32379377991846203
260.26-0.19765842954339363
270.27-0.08005206806781928
280.28-0.1390422692790659
290.29-0.011020136448015317
300.3-0.09936335164839094
310.31-0.1935607279056349
320.32-0.20013265916565423
330.33-0.13621884003313167
340.340.05506396229023293
350.35000000000000003-0.09539426910322614
360.36-0.03046087360049773
370.370.0358260135077053
380.38-0.02468276317222061
390.39-0.013365079629840827
400.40.03290530988704926
410.410000000000000030.09236541265760771
420.420.008829469357724084
430.43-0.09340391384573817
440.44-0.13022772024938606
450.45-0.11444680788475761
460.46-0.09004564385484443
470.47000000000000003-0.12388845592594633
480.48-0.16908921527982224
490.49-0.23621628297977046
500.5-0.06065877670252251
510.510.15528900551076183
520.520.2328522538070708
530.530.38654325208534185
540.540.3719318987324228
550.550.30069502196152453
560.560.14691883310326911
570.57000000000000010.1356408550242861
580.580.07342708661426188
590.59-0.04955297156102289
600.6-0.12172614517980676
610.61-0.05160754498887156
620.62-0.0326774321303532
630.63-0.10668989467443205
640.64-0.15389564561876834
650.65-0.1683840141746808
660.66-0.2358727277844425
670.67-0.2620766456348528
680.68-0.21696536899768884
690.6900000000000001-0.2766349569202509
700.7000000000000001-0.3277948769345407
710.71-0.11736641238444333
720.720.03680554556822604
730.73-0.1050711014114763
740.74-0.09345092092056338
750.75-0.2765450332422619
760.76-0.3061677367336552
770.77-0.2916400674250887
780.78-0.20597732277551606
790.79-0.15078081190766138
800.8-0.10821960357679204
810.81-0.2546565466130999
820.8200000000000001-0.3989215477491268
830.8300000000000001-0.40253088009985927
840.84-0.5033336522498485
850.85-0.3624046970598575
860.86-0.38363163356005403
870.87-0.4717094074313799
880.88-0.40878538884724347
890.89-0.41833995736628043
900.9-0.3960998494956141
910.91-0.32091340592646284
920.92-0.29185318206573546
930.93-0.2622038632209989
940.9400000000000001-0.347362634575315
950.9500000000000001-0.27233704267043973
960.96-0.205486021227324
970.97-0.25127382136745563
980.98-0.2135784229919815
990.99-0.13558674450100697
[28]:
# Draw the quantile field
processSample.computeQuantilePerComponent(0.9).drawMarginal(0)
[28]:
../../_images/examples_probabilistic_modeling_processsample_manipulation_9_0.png
[9]:
# Draw the field with interpolation
processSample.drawMarginal(0)
[9]:
../../_images/examples_probabilistic_modeling_processsample_manipulation_10_0.png
[14]:
processSample
[14]:
ty0y0...y0y0y0
00.00.6082016512190991-1.516964818462452...-1.28210333212461310.65681881927572042.317326540891351
10.010.18794474534061273-1.8438198135158375...-1.80307655832122141.01721010638308762.059358992840717
20.020.043580495738500424-1.6828293725405234...-1.70806108651218861.56274285563096221.7116099850802056
...
970.970.6379059880860732-1.0567978231908535...0.44255181856888176-0.19608426966000710.844559444932037
980.981.2606816514276786-0.875918616720255...0.40963620442024967-0.64272015758004230.47588466080317865
990.990.9210737505271945-1.0911123174517658...0.5118762676358366-0.66887054977374760.15237663260626474