FunctionalChaosAlgorithm¶

class
FunctionalChaosAlgorithm
(*args)¶ Functional chaos algorithm.
 Available constructors:
FunctionalChaosAlgorithm(inputSample, outputSample)
FunctionalChaosAlgorithm(inputSample, outputSample, distribution, adaptiveStrategy)
FunctionalChaosAlgorithm(inputSample, outputSample, distribution, adaptiveStrategy, projectionStrategy)
FunctionalChaosAlgorithm(model, distribution, adaptiveStrategy)
FunctionalChaosAlgorithm(model, distribution, adaptiveStrategy, projectionStrategy)
FunctionalChaosAlgorithm(inputSample, weights, outputSample, distribution, adaptiveStrategy)
FunctionalChaosAlgorithm(inputSample, weights, outputSample, distribution, adaptiveStrategy, projectionStrategy)
Parameters: inputSample, outputSample : 2d sequence of float
Sample of the input  output random vectors
model :
NumericalMathFunction
Model such as .
distribution :
Distribution
Distribution of the random vector
adaptiveStrategy :
AdaptiveStrategy
Strategy of selection of the different terms of the multivariate basis.
projectionStrategy :
ProjectionStrategy
Strategy of evaluation of the coefficients
weights : sequence of float
Weights associated to the data base
Default values are where N=inputSample.getSize()
See also
Notes
Consider with , and with finite variance: .
When , the functional chaos algorithm is used on each marginal of , using the same multivariate orthonormal basis for all the marginals. Thus, the algorithm is detailed here for a scalar output and .
Let be an isoprobabilistic transformation such that . We note , then .
Let be an orthonormal multivariate basis of .
Then the functional chaos decomposition of f writes:
which can be truncated to the finite set :
The approximation can be used to build an efficient random generator of based on the random vector . It writes:
For more details, see
FunctionalChaosRandomVector
.The functional chaos decomposition can be used to build a meta model of g, which writes:
If the basis has been obtained by tensorisation of univariate orthonormal basis, then the distribution writes . In that case only, the Sobol indices can easily be deduced from the coefficients .
We detail here all the steps required in order to create a functional chaos algorithm.
Step 1  Construction of the multivariate orthonormal basis: the multivariate orthonornal basis is built as the tensor product of orthonormal univariate families.
The univariate bases may be:
 polynomials: the associated distribution is continuous or discrete.
Note that it is possible to build the polynomial family orthonormal to any univariate
distribution under some conditions.
For more details, see
StandardDistributionPolynomialFactory
;  Haar wavelets: they enable to approximate functions with discontinuities.
For more details, see
HaarWaveletFactory
,;  Fourier series: for more details, see
FourierSeriesFactory
.
Furthermore, the numerotation of the multivariate orthonormal basis is given by an enumerate function which defines a regular way to generate the collection of degres used for the univariate polynomials : an enumerate function represents a bijection . See
LinearEnumerateFunction
orHyperbolicAnisotropicEnumerateFunction
for more details.Step 2  Truncation strategy of the multivariate orthonormal basis: a strategy must be chosen for the selection of the different terms of the multivariate basis. The selected terms are gathered in the subset K.
For more details on the possible strategies, see
FixedStrategy
,SequentialStrategy
andCleaningStrategy
.Step 3  Evaluation strategy of the coefficients: a strategy must be chosen for the estimation of te coefficients . The vector is equivalently defined by:
(1)¶
or
(2)¶
where the mean is evaluated with respect to the measure .
Relation (1) means that the coefficients minimize the quadratic error between the model and the polynomial approximation. For more details, see
LeastSquaresStrategy
.Relation (2) means that is the scalar product of the model with the kth element of the orthonormal basis . For more details, see
IntegrationStrategy
.Examples
Create the model:
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> inputDim = 1 >>> model = ot.SymbolicFunction(['x'], ['x*sin(x)']) >>> distribution = ot.ComposedDistribution([ot.Uniform()]*inputDim)
Build the multivariate orthonormal basis:
>>> polyColl = [0.0]*inputDim >>> for i in range(distribution.getDimension()): ... polyColl[i] = ot.StandardDistributionPolynomialFactory(distribution.getMarginal(i)) >>> enumerateFunction = ot.LinearEnumerateFunction(inputDim) >>> productBasis = ot.OrthogonalProductPolynomialFactory(polyColl, enumerateFunction)
Define the strategy to truncate the multivariate orthonormal basis: We choose all the polynomials of degree <= 4
>>> degree = 4 >>> indexMax = enumerateFunction.getStrataCumulatedCardinal(degree) >>> print(indexMax) 5
We keep all the polynomials of degree <= 4 (which corresponds to the 5 first ones):
>>> adaptiveStrategy = ot.FixedStrategy(productBasis, indexMax)
Define the evaluation strategy of the coefficients:
>>> samplingSize = 50 >>> experiment = ot.MonteCarloExperiment(samplingSize) >>> projectionStrategy = ot.LeastSquaresStrategy(experiment)
Create the Functional Chaos Algorithm:
>>> algo = ot.FunctionalChaosAlgorithm(model, distribution, adaptiveStrategy, ... projectionStrategy) >>> algo.run()
Get the result:
>>> functionalChaosResult = algo.getResult() >>> metamodel = functionalChaosResult.getMetaModel()
Test it:
>>> X = [0.5] >>> print(model(X)) [0.239713] >>> print(metamodel(X)) [0.239514]
Methods
getAdaptiveStrategy
()Get the adaptive strategy. getClassName
()Accessor to the object’s name. getDistribution
()Accessor to the joint probability density function of the physical input vector. getId
()Accessor to the object’s id. getInputSample
()Accessor to the input sample. getMaximumResidual
()Get the maximum residual. getName
()Accessor to the object’s name. getOutputSample
()Accessor to the output sample. getProjectionStrategy
()Get the projection strategy. getResult
()Get the results of the metamodel computation. getShadowedId
()Accessor to the object’s shadowed id. getVisibility
()Accessor to the object’s visibility state. hasName
()Test if the object is named. hasVisibleName
()Test if the object has a distinguishable name. run
()Compute the metamodel. setDistribution
(distribution)Accessor to the joint probability density function of the physical input vector. setMaximumResidual
(residual)Set the maximum residual. setName
(name)Accessor to the object’s name. setProjectionStrategy
(projectionStrategy)Set the projection strategy. setShadowedId
(id)Accessor to the object’s shadowed id. setVisibility
(visible)Accessor to the object’s visibility state. 
__init__
(*args)¶

getAdaptiveStrategy
()¶ Get the adaptive strategy.
Returns: adaptiveStrategy :
AdaptiveStrategy
Strategy of selection of the different terms of the multivariate basis.

getClassName
()¶ Accessor to the object’s name.
Returns: class_name : str
The object class name (object.__class__.__name__).

getDistribution
()¶ Accessor to the joint probability density function of the physical input vector.
Returns: distribution :
Distribution
Joint probability density function of the physical input vector.

getId
()¶ Accessor to the object’s id.
Returns: id : int
Internal unique identifier.

getInputSample
()¶ Accessor to the input sample.
Returns: inputSample :
NumericalSample
Input sample of a model evaluated apart.

getMaximumResidual
()¶ Get the maximum residual.
Returns: residual : float
Residual value needed in the projection strategy.
Default value is .

getName
()¶ Accessor to the object’s name.
Returns: name : str
The name of the object.

getOutputSample
()¶ Accessor to the output sample.
Returns: outputSample :
NumericalSample
Output sample of a model evaluated apart.

getProjectionStrategy
()¶ Get the projection strategy.
Returns: strategy :
ProjectionStrategy
Projection strategy.
Notes
The projection strategy selects the different terms of the multivariate basis to define the subset K.

getResult
()¶ Get the results of the metamodel computation.
Returns: result :
FunctionalChaosResult
Result structure, created by the method
run()
.

getShadowedId
()¶ Accessor to the object’s shadowed id.
Returns: id : int
Internal unique identifier.

getVisibility
()¶ Accessor to the object’s visibility state.
Returns: visible : bool
Visibility flag.

hasName
()¶ Test if the object is named.
Returns: hasName : bool
True if the name is not empty.

hasVisibleName
()¶ Test if the object has a distinguishable name.
Returns: hasVisibleName : bool
True if the name is not empty and not the default one.

run
()¶ Compute the metamodel.
Notes
Evaluates the metamodel and stores all the results in a result structure.

setDistribution
(distribution)¶ Accessor to the joint probability density function of the physical input vector.
Parameters: distribution :
Distribution
Joint probability density function of the physical input vector.

setMaximumResidual
(residual)¶ Set the maximum residual.
Parameters: residual : float
Residual value needed in the projection strategy.
Default value is .

setName
(name)¶ Accessor to the object’s name.
Parameters: name : str
The name of the object.

setProjectionStrategy
(projectionStrategy)¶ Set the projection strategy.
Parameters: strategy :
ProjectionStrategy
Strategy to estimate the coefficients .

setShadowedId
(id)¶ Accessor to the object’s shadowed id.
Parameters: id : int
Internal unique identifier.

setVisibility
(visible)¶ Accessor to the object’s visibility state.
Parameters: visible : bool
Visibility flag.