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:
- weightedExperiment
WeightedExperiment
The weighted experimental design.
- weightedExperiment
Methods
Compute the norm of the function.
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.
See also
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.inputDistribution, 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.inputDistribution, sampleSize) >>> integration = otexp.ExperimentIntegration(experiment) >>> functionNorm = integration.computeL2Norm(centeredIshigamiFunction) >>> print(functionNorm) [3.7...]
- __init__(*args)¶
- computeL2Norm(g)¶
Compute the norm of the function.
This method returns an approximation of the norm of the physical model:
where is the probability density function of the input random vector.
- Parameters:
- g
Function
The function which norm is to be computed.
- g
- Returns:
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.inputDistribution, 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:
where is the probability density function of the input random vector .
- Parameters:
- g
Function
The function to integrate.
- g
- Returns:
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.inputDistribution, ... 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