Create a functional basis processΒΆ

The objective of this example is to define X: \Omega \times \mathcal{D} \rightarrow \mathbb{R}^d a multivariate stochastic process of dimension d where \mathcal{D} \in \mathbb{R}^n, as a linear combination of K deterministic functions (\phi_i)_{i=1,\dots,K}: \mathbb{R}^n \rightarrow \mathbb{R}^d:

\begin{aligned}
  X(\omega,\vect{t})=\sum_{i=1}^KA_i(\omega)\phi_i(\vect{t})
\end{aligned}

where \vect{A}=(A_1,\dots, A_K) is a random vector of dimension K.

We suppose that \mathcal{M} is discretized on the mesh \mathcal{M} which has N vertices.

A realization of X on \mathcal{M} consists in generating a realization \vect{\alpha} of the random vector \vect{A} and in evaluating the functions (\phi_i)_{i=1,\dots,K} on the mesh \mathcal{M}.

If we note (\vect{x}_0, \dots, \vect{x}_{N-1}) the realization of X, where X(\omega, \vect{t}_k) = \vect{x}_k, we have:

\begin{aligned}
  \forall k \in [0, N-1], \quad \vect{x}_k = \sum_{i=1}^K\alpha_i\phi_i(\vect{t}_k)
\end{aligned}

import openturns as ot
import openturns.viewer as viewer

ot.Log.Show(ot.Log.NONE)

Define the coefficients distribution

mu = [2.0] * 2
sigma = [5.0] * 2
R = ot.CorrelationMatrix(2)
coefDist = ot.Normal(mu, sigma, R)

Create a basis of functions

phi_1 = ot.SymbolicFunction(["t"], ["sin(t)"])
phi_2 = ot.SymbolicFunction(["t"], ["cos(t)^2"])
myBasis = ot.Basis([phi_1, phi_2])

Create the mesh

myMesh = ot.RegularGrid(0.0, 0.1, 100)

Create the process

process = ot.FunctionalBasisProcess(coefDist, myBasis, myMesh)

Draw a sample

N = 6
sample = process.getSample(N)
graph = sample.drawMarginal(0)
graph.setTitle(str(N) + " realizations of functional basis process")
view = viewer.View(graph)
6 realizations of functional basis process