Apply a Box-Cox transformation to a FieldΒΆ

In this example we are going to modify a Field through a Box-Cox transformation.

In [57]:
from __future__ import print_function
import openturns as ot
In [58]:
# Define a process
myIndices= ot.Indices([10,5])
myMesher =ot.IntervalMesher(myIndices)
myInterval = ot.Interval([0.0, 0.0], [2.0, 1.0])
myMesh = myMesher.build(myInterval)
amplitude = [1.0]
scale = [0.2, 0.2]
myCovModel = ot.ExponentialModel(scale, amplitude)
myXproc = ot.GaussianProcess(myCovModel, myMesh)
g = ot.SymbolicFunction(['x1'],  ['exp(x1)'])
myDynTransform = ot.ValueFunction(g, 2)
myXtProcess = ot.CompositeProcess(myDynTransform, myXproc)
In [59]:
# Draw a field
field = myXtProcess.getRealization()
field.drawMarginal(0)
Out[59]:
../../_images/examples_probabilistic_modeling_box_cox_transform_4_0.svg
In [63]:
# Draw values
marginal = ot.HistogramFactory().build(field.getValues())
marginal.drawPDF()
Out[63]:
../../_images/examples_probabilistic_modeling_box_cox_transform_5_0.svg
In [60]:
# Build the transformed field through Box-Cox
myModelTransform = ot.BoxCoxFactory().build(field)
myStabilizedField = myModelTransform(field)
In [62]:
# Draw values
marginal = ot.HistogramFactory().build(myStabilizedField.getValues())
marginal.drawPDF()
Out[62]:
../../_images/examples_probabilistic_modeling_box_cox_transform_7_0.svg