GaussLPQuadratureRule¶
- class GaussLPQuadratureRule(*args)¶
Immutable Gauss-LP quadrature rule.
Warning
This class is experimental and likely to be modified in future releases. To use it, import the
openturns.experimentalsubmodule.This class stores the nodes and weights produced by
GaussLPQuadrature. Unlike the builder, its size is known when it is constructed: it is the number of nodes actually returned by the algorithm, which may be smaller than the requested number of functions. The stored distribution is the measure against which the rule was built.The rule is immutable:
setSize()rejects any size other than the stored one andsetDistribution()always raises, so a built rule stays fixed.generateWithWeights()always returns the same nodes and weights, andisRandom()returnsFalse.- Parameters:
- nodes
Sample The quadrature nodes.
- weights
Point The quadrature weights, one per node.
- measure
Distribution The measure against which the rule was built.
- nodes
Methods
generate()Generate points according to the type of the experiment.
Generate the stored quadrature rule.
Accessor to the object's name.
Accessor to the distribution.
getName()Accessor to the object's name.
getSize()Accessor to the size of the generated sample.
hasName()Test if the object is named.
Tell whether the weights are uniform.
isRandom()Tell whether the rule is random.
setDistribution(distribution)Set the measure.
setLevels(levels)Accessor to the experiment nesting levels.
setName(name)Accessor to the object's name.
setSize(size)Set the number of nodes.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> measure = ot.JointDistribution([ot.Uniform(0.0, 1.0)] * 2) >>> functions = [ot.SymbolicFunction(['x', 'y'], [formula]) ... for formula in ['1.0', 'x', 'y', 'x * y']] >>> builder = otexp.GaussLPQuadrature(functions, measure) >>> rule = builder.buildRule(3) >>> nodes, weights = rule.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 the stored quadrature rule.
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- 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.
- getSize()¶
Accessor to the size of the generated sample.
- Returns:
- sizepositive int
Number
of points constituting the design of experiments.
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- hasUniformWeights()¶
Tell whether the weights are uniform.
- Returns:
- uniformbool
Truewhen all the weights are equal to1 / getSize().
- isRandom()¶
Tell whether the rule is random.
- Returns:
- randombool
Always
False: the rule is built once and then stored.
- setDistribution(distribution)¶
Set the measure.
The measure of a quadrature rule is fixed when the rule is built. Any call raises an exception.
- Parameters:
- distribution
Distribution The requested measure.
- 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.
- setSize(size)¶
Set the number of nodes.
The size of a quadrature rule is fixed by its nodes. Setting the current size is a no-op; setting another size raises an exception.
- Parameters:
- sizeint
The requested size.
Examples using the class¶
Build a sparse quadrature rule with the Gauss-LP algorithm
Orthonormalize a finite set of functions on a multivariate domain
OpenTURNS