FejerExperiment¶
(Source code
, svg
)
- class FejerExperiment(*args)¶
Fejer experiment.
Warning
This class is experimental and likely to be modified in future releases. To use it, import the
openturns.experimental
submodule.This class computes Fejer and Clenshaw–Curtis quadrature, see also here
For any
, let
. The Clenshaw-Curtis nodes are:
for any
and its associated weights are:
where:
and:
The type-1 Fejer quadrature rule uses the nodes:
for any
and the associated weights are:
Finally, the type-2 Fejer quadrature rule is very close to the Clenshaw-Curtis rule. The two methods share the same nodes (except the endpoints that are set to 0 within the Fejer method). The weights of the type-2 Fejer quadrature rule are:
for any
.
- Parameters:
- discretizationsequence of int, optional
The number of nodes in each dimension. The sequence must be non-empty and must contain only positive values. The default discretization is FejerExperiment-DefaultMarginalNodesNumber in each dimension, see
ResourceMap
.- ruleint, optional
Possible values include:
ot.FejerExperiment.FEJERTYPE1,
ot.FejerExperiment.FEJERTYPE2,
ot.FejerExperiment.CLENSHAWCURTIS.
Default is ot.FejerExperiment.CLENSHAWCURTIS
Methods
generate
()Generate points according to the type of the experiment.
Generate points and their associated weight according to the type of the experiment.
Accessor to the design bounds.
Accessor to the object's name.
Accessor to the discretization of the tensorized rule.
Accessor to the distribution.
getName
()Accessor to the object's name.
Accessor to the generation rule.
getSize
()Accessor to the size of the generated sample.
Accessor to the levels interpretation flag.
hasName
()Test if the object is named.
Ask whether the experiment has uniform weights.
isRandom
()Accessor to the randomness of quadrature.
setBounds
(bounds)Accessor to the design bounds.
setDiscretization
(discretization)Accessor to the discretization of the tensorized rule.
setDistribution
(distribution)Accessor to the distribution.
setLevels
(levels)Accessor to the experiment nesting levels.
setName
(name)Accessor to the object's name.
setRuleType
(ruleType)Accessor to the generation rule.
setSize
(size)Accessor to the size of the generated sample.
setUseNestedLevels
(useNestedLevels)Accessor to the levels interpretation flag.
See also
Examples
Create an experiment:
>>> import openturns as ot >>> import openturns.experimental as otexp >>> rule = otexp.FejerExperiment.FEJERTYPE1 >>> experiment = otexp.FejerExperiment([3], rule) >>> experiment.setBounds(ot.Interval(4.0, 5.0)) >>> nodes, weights = experiment.generateWithWeights()
- __init__(*args)¶
- generate()¶
Generate points according to the type of the experiment.
- Returns:
- sample
Sample
Points
of the design of experiments. The sampling method is defined by the type of the weighted experiment.
- sample
Examples
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> myExperiment = ot.MonteCarloExperiment(ot.Normal(2), 5) >>> sample = myExperiment.generate() >>> print(sample) [ X0 X1 ] 0 : [ 0.608202 -1.26617 ] 1 : [ -0.438266 1.20548 ] 2 : [ -2.18139 0.350042 ] 3 : [ -0.355007 1.43725 ] 4 : [ 0.810668 0.793156 ]
- generateWithWeights()¶
Generate points and their associated weight according to the type of the experiment.
- Returns:
Examples
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> myExperiment = ot.MonteCarloExperiment(ot.Normal(2), 5) >>> sample, weights = myExperiment.generateWithWeights() >>> print(sample) [ X0 X1 ] 0 : [ 0.608202 -1.26617 ] 1 : [ -0.438266 1.20548 ] 2 : [ -2.18139 0.350042 ] 3 : [ -0.355007 1.43725 ] 4 : [ 0.810668 0.793156 ] >>> print(weights) [0.2,0.2,0.2,0.2,0.2]
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getDiscretization()¶
Accessor to the discretization of the tensorized rule.
- Returns:
- discretization
Indices
The number of integration point in each dimension.
- discretization
- getDistribution()¶
Accessor to the distribution.
- Returns:
- distribution
Distribution
Distribution of the input random vector.
- distribution
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- getRuleType()¶
Accessor to the generation rule.
- Returns:
- ruleTypeint
The generation rule.
- getSize()¶
Accessor to the size of the generated sample.
- Returns:
- sizepositive int
Number
of points constituting the design of experiments.
- getUseNestedLevels()¶
Accessor to the levels interpretation flag.
- Returns:
- useNestedLevelsbool
Whether the level is raised to the power of two (only for FEJERTYPE2, CLENSHAWCURTIS nested rules) or interpreted as raw size.
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- hasUniformWeights()¶
Ask whether the experiment has uniform weights.
- Returns:
- hasUniformWeightsbool
Whether the experiment has uniform weights.
- isRandom()¶
Accessor to the randomness of quadrature.
- Parameters:
- isRandombool
Is true if the design of experiments is random. Otherwise, the design of experiment is assumed to be deterministic.
- setBounds(bounds)¶
Accessor to the design bounds.
- Parameters:
- bounds
Interval
The bounds used for rescaling.
- bounds
- setDiscretization(discretization)¶
Accessor to the discretization of the tensorized rule.
- Parameters:
- discretization
Indices
The number of integration point in each dimension.
- discretization
- setDistribution(distribution)¶
Accessor to the distribution.
- Parameters:
- distribution
Distribution
Distribution of the input random vector.
- distribution
- setLevels(levels)¶
Accessor to the experiment nesting levels.
- Parameters:
- levelssequence of int
Nesting level for each component.
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.
- setRuleType(ruleType)¶
Accessor to the generation rule.
- Parameters:
- ruleTypeint
The generation rule. Possible values include:
ot.FejerExperiment.FEJERTYPE1,
ot.FejerExperiment.FEJERTYPE2,
ot.FejerExperiment.CLENSHAWCURTIS.
- setSize(size)¶
Accessor to the size of the generated sample.
- Parameters:
- sizepositive int
Number
of points constituting the design of experiments.
- setUseNestedLevels(useNestedLevels)¶
Accessor to the levels interpretation flag.
- Parameters:
- useNestedLevelsbool
Whether the level is raised to the power of two (only for FEJERTYPE2, CLENSHAWCURTIS nested rules) or interpreted as raw size.