Create a functional basis processΒΆ

In this basic example we are going to build a functional basis process defined by a basis and the distribution of the coefficients on that basis.

In [7]:
from __future__ import print_function
import openturns as ot
import math as m
In [8]:
# Define the coefficients distribution
mu = [2.0]*2
sigma = [5.0]*2
R = ot.CorrelationMatrix(2)
coefDist = ot.Normal(mu, sigma, R)
In [9]:
# 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])
In [10]:
# Create the mesh
myMesh = ot.RegularGrid(0.0, 0.1, 10)
In [11]:
# Create the process
process = ot.FunctionalBasisProcess(coefDist, myBasis, myMesh)
print(process)
class=ProcessImplementation dimension=1 description=[y0] mesh=class=Mesh name=Unnamed dimension=1 vertices=class=Sample name=Unnamed implementation=class=SampleImplementation name=Unnamed size=10 dimension=1 description=[t] data=[[0],[0.1],[0.2],[0.3],[0.4],[0.5],[0.6],[0.7],[0.8],[0.9]] simplices=[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9]]
In [12]:
# Draw a sample
sample = process.getSample(6)
sample.drawMarginal(0)
Out[12]:
../../_images/examples_probabilistic_modeling_functional_basis_process_7_0.svg