FejerExperiment

(Source code, svg)

../../_images/FejerExperiment.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 k=0,1,...,n-1, let \theta_k = \dfrac{k\pi}{n}. The Clenshaw-Curtis nodes are:

x_k = \cos(\theta_k)

for any k=0,1,...,n-1 and its associated weights are:

w_k = \dfrac{c_k}{n}\left(1-\sum_{j=1}^{\lfloor n/2\rfloor}\dfrac{b_j}{4j^2-1}\cos\left(2j\theta_k\right)\right)

where:

b_j =
\begin{cases}
2 & \textrm{ if } j < n/2, \\
1 & \textrm{ otherwise},
\end{cases}

and:

c_k =
\begin{cases}
1 & \textrm{ if } k = 0 \textrm{ or } n - 1, \\
2 & \textrm{ otherwise}.
\end{cases}

The type-1 Fejer quadrature rule uses the nodes:

x_k = \cos(\theta_{k + 1/2})

for any k=0,1,...,n-1 and the associated weights are:

w_k = \dfrac{2}{n}\left(1-2\sum_{j=1}^{\lfloor n/2\rfloor}\dfrac{1}{4j^2-1}\cos\left(j\theta_{2k+1}\right)\right)

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:

w_k=\dfrac{4}{n+1}\sin\theta_k\sum_{j=1}^{\lfloor n/2\rfloor}\dfrac{\sin\left((2j-1)\theta_k\right)}{2j-1}

for any k=0,1,...,n-1.

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.

generateWithWeights()

Generate points and their associated weight according to the type of the experiment.

getBounds()

Accessor to the design bounds.

getClassName()

Accessor to the object's name.

getDiscretization()

Accessor to the discretization of the tensorized rule.

getDistribution()

Accessor to the distribution.

getName()

Accessor to the object's name.

getRuleType()

Accessor to the generation rule.

getSize()

Accessor to the size of the generated sample.

getUseNestedLevels()

Accessor to the levels interpretation flag.

hasName()

Test if the object is named.

hasUniformWeights()

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.

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:
sampleSample

Points (\inputReal_i)_{i = 1, ..., \sampleSize} of the design of experiments. The sampling method is defined by the type of the weighted experiment.

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:
sampleSample

The points of the design of experiments. The sampling method is defined by the nature of the experiment.

weightsPoint of size \sampleSize

Weights (w_i)_{i = 1, ..., \sampleSize} associated with the points. By default, all the weights are equal to \frac{1}{\sampleSize}.

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]
getBounds()

Accessor to the design bounds.

Returns:
boundsInterval

The bounds used for rescaling.

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:
discretizationIndices

The number of integration point in each dimension.

getDistribution()

Accessor to the distribution.

Returns:
distributionDistribution

Distribution of the input random vector.

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 \sampleSize 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:
boundsInterval

The bounds used for rescaling.

setDiscretization(discretization)

Accessor to the discretization of the tensorized rule.

Parameters:
discretizationIndices

The number of integration point in each dimension.

setDistribution(distribution)

Accessor to the distribution.

Parameters:
distributionDistribution

Distribution of the input random vector.

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 \sampleSize 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.