BasisOrthonormalizationFactory

class BasisOrthonormalizationFactory(*args)

Basis orthonormalization factory.

Warning

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

This class computes a finite set of orthonormal functions from the first s elements of a source OrthogonalBasis, with respect to a target measure. It uses a BasisOrthonormalizationAlgorithm to compute the orthonormal basis and a GaussLPQuadrature built from the orthonormal functions and the target measure to construct quadrature rules. The basis comes from the QR factorization of the weighted design matrix when the integration rule exposes its nodes, and from the Cholesky factorization of the Gram matrix for opaque rules.

The source basis carries an instrumental measure, against which its functions are naturally orthogonal. The target measure is the measure against which the orthonormal basis is built. The two measures must have the same dimension and the support of the target measure must be contained in the support of the instrumental measure; an exception is raised otherwise. A discrete instrumental measure is exempt from the range check.

The initial functions do not need to be orthonormal with respect to the target measure: the factory computes an orthonormal basis of the vector space they span.

The integration algorithm is not a constructor argument: the default target-measure-adapted rule is used unless setIntegrationAlgorithm() replaces it, so that the basis, the target measure and the rule are always set consistently.

Parameters:
basisOrthogonalBasis

Source orthogonal basis whose first elements are orthonormalized. Its measure is the instrumental measure.

targetMeasureDistribution

Target measure against which the orthonormal basis is built.

sizeint

Number of first elements of the source basis to orthonormalize. It must be positive.

Methods

add(elt)

Add a function.

build(*args)

Build the orthonormal function of given index.

buildQuadrature(n)

Build a quadrature rule.

buildQuadratureRule(n)

Build a quadrature rule as a weighted experiment.

getClassName()

Accessor to the object's name.

getCoefficients()

Accessor to the coefficient matrix.

getEnumerateFunction()

Return the enumerate function.

getInputDimension()

Get the input dimension of the Basis.

getIntegrationAlgorithm()

Accessor to the integration algorithm.

getMarginal(indices)

Get the marginal orthogonal functions.

getMeasure()

Get the measure upon which the basis is orthogonal.

getName()

Accessor to the object's name.

getOrthonormalizationAlgorithm()

Accessor to the orthonormalization algorithm.

getOutputDimension()

Get the output dimension of the Basis.

getSize()

Accessor to the number of orthonormal functions.

getSubBasis(indices)

Get a sub-basis of the Basis.

hasName()

Test if the object is named.

isFinite()

Tell whether the basis is finite.

isOrthogonal()

Tell whether the basis is orthogonal.

isTensorProduct()

Tell whether the basis is a tensor product

setIntegrationAlgorithm(integrationAlgorithm)

Accessor to the integration algorithm.

setName(name)

Accessor to the object's name.

equals

Notes

This class has no dedicated ResourceMap key: refer to the BasisOrthonormalizationAlgorithm and GaussLPQuadrature API documentation to learn which numerical parameters tune the computation.

Examples

>>> import openturns as ot
>>> import openturns.experimental as otexp
>>> dim = 2
>>> distribution = ot.JointDistribution(
...     [ot.Uniform(-1.0, 1.0)] * dim, ot.FrankCopula(4.0))
>>> legendreBasis = ot.OrthogonalProductPolynomialFactory(
...     [ot.LegendreFactory()] * dim)
>>> factory = otexp.BasisOrthonormalizationFactory(
...     legendreBasis, distribution, 6)
>>> factory.getSize()
6
>>> f0 = factory.build(0)
__init__(*args)
add(elt)

Add a function.

Parameters:
functiona Function

Function to be added.

build(*args)

Build the orthonormal function of given index.

Parameters:
indexint

Index of the function to build (0-based).

Returns:
funcFunction

The orthonormal function.

buildQuadrature(n)

Build a quadrature rule.

Build a quadrature rule integrating the first n orthonormal functions against the target measure. Uses the Gauss-LP approach: linear programming followed by clustering and local refinement. The returned number of nodes is at most n: a natural linear-programming support smaller than n is preserved. The moments are reproduced up to the refinement tolerance; when the residual exceeds it, a warning is logged and the best rule found is returned.

In Python, the two outputs are returned as a tuple and can be unpacked as nodes, weights = factory.buildQuadrature(n).

Note

The linear program requires HiGHS support. When OpenTURNS is built without HiGHS, the builder falls back to a refined measure-adapted tensor rule and emits a warning; it raises an exception when that rule has fewer than n nodes.

Parameters:
nint

Number of orthonormal functions whose moments are reproduced.

Returns:
nodesSample

The quadrature nodes.

weightsPoint

The quadrature weights.

buildQuadratureRule(n)

Build a quadrature rule as a weighted experiment.

Builds the rule with GaussLPQuadrature from the orthonormal functions and the target measure, and returns it as a WeightedExperiment whose implementation is the immutable GaussLPQuadratureRule. The rule stores the nodes, the weights and the target measure; its size is the actual number of nodes, which is at most n.

Note

The linear program requires HiGHS support. When OpenTURNS is built without HiGHS, the builder falls back to a refined measure-adapted tensor rule and emits a warning; it raises an exception when that rule has fewer than n nodes.

Parameters:
nint

Number of orthonormal functions whose moments are reproduced.

Returns:
ruleWeightedExperiment

The quadrature rule as a weighted experiment, whose implementation is a GaussLPQuadratureRule.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getCoefficients()

Accessor to the coefficient matrix.

Column j of the matrix contains the coefficients of the j-th orthonormal function in the first elements of the orthogonal basis.

Returns:
coefficientsSquareMatrix

Coefficient matrix of the orthonormal functions.

getEnumerateFunction()

Return the enumerate function.

Returns:
enumerateFunctionEnumerateFunction

Enumerate function that translates unidimensional indices into multidimensional indices.

getInputDimension()

Get the input dimension of the Basis.

Returns:
inDimint

Input dimension of the functions.

getIntegrationAlgorithm()

Accessor to the integration algorithm.

Returns:
integrationAlgorithmIntegrationAlgorithm

Integration algorithm.

getMarginal(indices)

Get the marginal orthogonal functions.

Parameters:
indicessequence of int, 0 \leq i < \inputDim

List of marginal indices of the input variables.

Returns:
functionFamilylistlist of OrthogonalBasis

The marginal orthogonal functions.

getMeasure()

Get the measure upon which the basis is orthogonal.

Returns:
measureDistribution

Measure upon which the basis is orthogonal.

Examples

>>> import openturns as ot
>>> # Create an orthogonal basis
>>> polynomialCollection = [ot.LegendreFactory(), ot.LaguerreFactory(), ot.HermiteFactory()]
>>> productBasis = ot.OrthogonalProductPolynomialFactory(polynomialCollection)
>>> measure = productBasis.getMeasure()
>>> print(measure.getMarginal(0))
Uniform(a = -1, b = 1)
>>> print(measure.getMarginal(1))
Gamma(k = 1, lambda = 1, gamma = 0)
>>> print(measure.getMarginal(2))
Normal(mu = 0, sigma = 1)
getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getOrthonormalizationAlgorithm()

Accessor to the orthonormalization algorithm.

Returns:
algoBasisOrthonormalizationAlgorithm

The orthonormalization algorithm holding the source basis, the target measure, the size and the integration rule.

getOutputDimension()

Get the output dimension of the Basis.

Returns:
outDimint

Output dimension of the functions.

getSize()

Accessor to the number of orthonormal functions.

Returns:
sizeint

Number of first elements of the orthogonal basis which are orthonormalized.

getSubBasis(indices)

Get a sub-basis of the Basis.

Parameters:
indiceslist of int

Indices of the terms of the Basis put in the sub-basis.

Returns:
subBasislist of Function

Functions defining a sub-basis.

Examples

>>> import openturns as ot
>>> dimension = 3
>>> input = ['x0', 'x1', 'x2']
>>> functions = []
>>> for i in range(dimension):
...     functions.append(ot.SymbolicFunction(input, [input[i]]))
>>> basis = ot.Basis(functions)
>>> subbasis = basis.getSubBasis([1])
>>> print(subbasis[0].getEvaluation())
[x0,x1,x2]->[x1]
hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

isFinite()

Tell whether the basis is finite.

Returns:
isFinitebool

True if the basis is finite.

isOrthogonal()

Tell whether the basis is orthogonal.

Returns:
isOrthogonalbool

True if the basis is orthogonal.

isTensorProduct()

Tell whether the basis is a tensor product

Returns:
isTensorProductbool

True if the basis is a tensor product.

setIntegrationAlgorithm(integrationAlgorithm)

Accessor to the integration algorithm.

Any IntegrationAlgorithm can be used, including an ExperimentIntegration built from any weighted experiment. The experiment is validated when the orthonormal basis is computed. For an experiment, a continuous experiment distribution must be the target measure, and its instrumental distribution must contain the support of the target measure, otherwise an exception is raised. If the experiment distribution does not implement equality, the equality check is skipped and the caller is responsible for its compatibility with the target measure. A discrete experiment such as FixedExperiment is exempt from the equality and range checks because its distribution is the empirical measure supported by its nodes.

Parameters:
integrationAlgorithmIntegrationAlgorithm

Integration algorithm.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

Examples using the class

Orthonormalize a finite set of functions on a multivariate domain

Orthonormalize a finite set of functions on a multivariate domain