ExperimentIntegration

class ExperimentIntegration(*args)

Create a quadrature rule for numerical integration based on a weighted experiment.

Warning

This class is experimental and likely to be modified in future releases. To use it, import the openturns.experimental submodule.

Parameters:
weightedExperimentWeightedExperiment

The weighted experimental design.

Notes

This class creates an integration method using a weighted experimental design. It can be used on a function with arbitrary input and output.

Examples

Integrate the Ishigami physical model.

>>> import openturns as ot
>>> import openturns.experimental as otexp
>>> from openturns.usecases import ishigami_function
>>> im = ishigami_function.IshigamiModel()
>>> ot.RandomGenerator.SetSeed(0)
>>> sampleSize = 32768
>>> experiment = ot.MonteCarloExperiment(im.distributionX, sampleSize)
>>> integration = otexp.ExperimentIntegration(experiment)
>>> approximatedOutputMean = integration.integrate(im.model)
>>> print(approximatedOutputMean)
[3.5...]

Compute the L2 norm of a function.

>>> im = ishigami_function.IshigamiModel()
>>> centeredIshigamiFunction = ot.SymbolicFunction(
...     ['x1', 'x2', 'x3'],
...     ['sin(x1) + 7 * (sin(x2))^2 + 0.1 * x3^4 * sin(x1) - 3.5']
... )
>>> ot.RandomGenerator.SetSeed(0)
>>> sampleSize = 65536
>>> experiment = ot.MonteCarloExperiment(im.distributionX, sampleSize)
>>> integration = otexp.ExperimentIntegration(experiment)
>>> functionNorm = integration.computeL2Norm(centeredIshigamiFunction)
>>> print(functionNorm)
[3.7...]

Methods

computeL2Norm(g)

Compute the norm of the function.

getClassName()

Accessor to the object's name.

getName()

Accessor to the object's name.

hasName()

Test if the object is named.

integrate(g)

Integrate the function.

setName(name)

Accessor to the object's name.

__init__(*args)
computeL2Norm(g)

Compute the norm of the function.

This method returns an approximation of the L^2(\inputProbabilityDensityFunction) norm of the physical model:

\|\model\|_{L^2(\inputProbabilityDensityFunction)}
& = \left( \Expect{\model(\inputRV)^2} \right)^{1/2} \\
& = \left( \int_{\physicalInputSpace} \left(\model(\inputReal)\right)^2
\inputProbabilityDensityFunction(\inputReal) d\inputReal \right)^{1/2}

where \inputProbabilityDensityFunction is the probability density function of the input random vector.

Parameters:
gFunction

The function which norm is to be computed.

Returns:
functionNormPoint

The approximated L2 norm of the function. The dimension of the Point is equal to the output dimension of the function g.

Examples

>>> import openturns as ot
>>> import openturns.experimental as otexp
>>> import math
>>> from openturns.usecases import ishigami_function
>>> im = ishigami_function.IshigamiModel()
>>> print(math.sqrt(im.variance))
3.72...
>>> centeredIshigamiFunction = ot.SymbolicFunction(['x1', 'x2', 'x3'],
... ['sin(x1) + 7 * (sin(x2))^2 + 0.1 * x3^4 * sin(x1) - 3.5'])
>>> sampleSize = 2 ** 12  # Sobol' sequence is a base 2 sequence
>>> sequence = ot.SobolSequence(im.dim)
>>> experiment = ot.LowDiscrepancyExperiment(sequence, im.distributionX, sampleSize, False)
>>> integration = otexp.ExperimentIntegration(experiment)
>>> functionNorm = integration.computeL2Norm(centeredIshigamiFunction)
>>> print(functionNorm[0])
3.7...
getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

integrate(g)

Integrate the function.

This method returns an approximation of the expected value of the physical model:

\Expect{ \model(\inputRV)}
= \int_{\physicalInputSpace} \model(\inputReal) 
\inputProbabilityDensityFunction(\inputReal) d\inputReal

where \inputProbabilityDensityFunction is the probability density function of the input random vector \inputRV.

Parameters:
gFunction

The function to integrate.

Returns:
approximateIntegralPoint

The approximated integral of the function. The dimension of the Point is equal to the output dimension of the function g.

Examples

>>> import openturns as ot
>>> import openturns.experimental as otexp
>>> from openturns.usecases import ishigami_function
>>> im = ishigami_function.IshigamiModel()
>>> print(im.expectation)
3.5
>>> sampleSize = 2 ** 12  # Sobol' sequence is a base 2 sequence
>>> sequence = ot.SobolSequence(im.dim)
>>> experiment = ot.LowDiscrepancyExperiment(sequence, im.distributionX, 
...                                          sampleSize, False)
>>> integration = otexp.ExperimentIntegration(experiment)
>>> approximatedOutputMean = integration.integrate(im.model)
>>> print(approximatedOutputMean[0])
3.5...
setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

Examples using the class

Compute the L2 error between two functions

Compute the L2 error between two functions