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.experimentalsubmodule.This class computes a finite set of orthonormal functions from the first
elements of a source
OrthogonalBasis, with respect to a target measure. It uses aBasisOrthonormalizationAlgorithmto compute the orthonormal basis and aGaussLPQuadraturebuilt 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:
- basis
OrthogonalBasis Source orthogonal basis whose first elements are orthonormalized. Its measure is the instrumental measure.
- targetMeasure
Distribution Target measure against which the orthonormal basis is built.
- sizeint
Number of first elements of the source basis to orthonormalize. It must be positive.
- basis
Methods
add(elt)Add a function.
build(*args)Build the orthonormal function of given index.
Build a quadrature rule.
Build a quadrature rule as a weighted experiment.
Accessor to the object's name.
Accessor to the coefficient matrix.
Return the enumerate function.
Get the input dimension of the Basis.
Accessor to the integration algorithm.
getMarginal(indices)Get the marginal orthogonal functions.
Get the measure upon which the basis is orthogonal.
getName()Accessor to the object's name.
Accessor to the orthonormalization algorithm.
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.
Tell whether the basis is orthogonal.
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
ResourceMapkey: refer to theBasisOrthonormalizationAlgorithmandGaussLPQuadratureAPI 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)¶
- build(*args)¶
Build the orthonormal function of given index.
- Parameters:
- indexint
Index of the function to build (0-based).
- Returns:
- func
Function The orthonormal function.
- func
- 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 thannis 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
nnodes.
- buildQuadratureRule(n)¶
Build a quadrature rule as a weighted experiment.
Builds the rule with
GaussLPQuadraturefrom the orthonormal functions and the target measure, and returns it as aWeightedExperimentwhose implementation is the immutableGaussLPQuadratureRule. The rule stores the nodes, the weights and the target measure; its size is the actual number of nodes, which is at mostn.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
nnodes.- Parameters:
- nint
Number of orthonormal functions whose moments are reproduced.
- Returns:
- rule
WeightedExperiment The quadrature rule as a weighted experiment, whose implementation is a
GaussLPQuadratureRule.
- rule
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getCoefficients()¶
Accessor to the coefficient matrix.
Column
of the matrix contains the coefficients of the
-th orthonormal function in the first elements of the orthogonal basis.
- Returns:
- coefficients
SquareMatrix Coefficient matrix of the orthonormal functions.
- coefficients
- getEnumerateFunction()¶
Return the enumerate function.
- Returns:
- enumerateFunction
EnumerateFunction Enumerate function that translates unidimensional indices into multidimensional indices.
- enumerateFunction
- getInputDimension()¶
Get the input dimension of the Basis.
- Returns:
- inDimint
Input dimension of the functions.
- getIntegrationAlgorithm()¶
Accessor to the integration algorithm.
- Returns:
- integrationAlgorithm
IntegrationAlgorithm Integration algorithm.
- integrationAlgorithm
- getMarginal(indices)¶
Get the marginal orthogonal functions.
- Parameters:
- indicessequence of int,
List of marginal indices of the input variables.
- indicessequence of int,
- Returns:
- functionFamilylistlist of
OrthogonalBasis The marginal orthogonal functions.
- functionFamilylistlist of
- getMeasure()¶
Get the measure upon which the basis is orthogonal.
- Returns:
- measure
Distribution Measure upon which the basis is orthogonal.
- measure
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:
- algo
BasisOrthonormalizationAlgorithm The orthonormalization algorithm holding the source basis, the target measure, the size and the integration rule.
- algo
- 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.
- subBasislist of
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
IntegrationAlgorithmcan be used, including anExperimentIntegrationbuilt 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 asFixedExperimentis exempt from the equality and range checks because its distribution is the empirical measure supported by its nodes.- Parameters:
- integrationAlgorithm
IntegrationAlgorithm Integration algorithm.
- integrationAlgorithm
- 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
OpenTURNS