FiniteOrthogonalFunctionFactory¶
- class FiniteOrthogonalFunctionFactory(*args)¶
FiniteOrthogonalFunction orthonormal multivariate functional family.
Warning
This class is experimental and likely to be modified in future releases. To use it, import the
openturns.experimentalsubmodule.- Parameters:
- functionssequence of
Function The finite set of functions orthogonal wrt the given measure.
- measure
Distribution The measure defining the inner product of the factory.
- functionssequence of
Methods
add(elt)Add a function.
build(*args)Get the term of the basis collection at a given index or multi-indices.
Accessor to the object's name.
Return the enumerate function.
Accessor to the collection of functions.
Get the input dimension of the Basis.
getMarginal(indices)Get the marginal orthogonal functions.
Get the measure upon which the basis is orthogonal.
getName()Accessor to the object's name.
Get the output dimension of the Basis.
getSize()Get the size of the Basis.
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
setFunctionsCollection(functions)Accessor to the collection of functions defining the basis.
setName(name)Accessor to the object's name.
See also
Notes
This class implements a user-defined multivariate orthonormal basis associated with an arbitrary multidimensional distribution.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> mean = [0.0] * 2 >>> std = [1.0] * 2 >>> R = ot.CorrelationMatrix([[1.0, 0.8], [0.8, 1.0]]) >>> distribution = ot.Normal(mean, std, R) >>> f0 = ot.SymbolicFunction(['x0', 'x1'], ['1.0']) >>> f1 = ot.SymbolicFunction(['x0', 'x1'], ['x0']) >>> f2 = ot.SymbolicFunction(['x0', 'x1'], ['-4.0 * x0 / 3.0 + 5.0 * x1 / 3.0']) >>> f3 = ot.SymbolicFunction(['x0', 'x1'], ['-1.0 / sqrt(2.0) + x0^2 / sqrt(2)']) >>> f4 = ot.SymbolicFunction(['x0', 'x1'], ['-4.0 / 3.0 - 1.885618083165693 * (-1.0 / sqrt(2.0) + x0^2 / sqrt(2.0)) + 5.0 * x0 * x1 / 3.0']) >>> f5 = ot.SymbolicFunction(['x0', 'x1'], ['2.5141574442076222 + 16.0 / 9.0 * (-1.0 / sqrt(2.0) + x0^2 / sqrt(2.0)) - 3.142696805266918 * x0 * x1 + 25.0 / 9.0 * (-1.0 / sqrt(2.0) + x1^2 / sqrt(2.0))']) >>> initialBasis = [f0, f1, f2, f3, f4, f5] >>> factory = otexp.FiniteOrthogonalFunctionFactory(initialBasis, distribution) >>> point = [0.5] * 2 >>> for i in range(len(initialBasis)): ... value = factory.build(i)(point) ... print(f'FiniteOrthogonalFunction_{i}({point})={value}') FiniteOrthogonalFunction_0([0.5, 0.5])=[1] FiniteOrthogonalFunction_1([0.5, 0.5])=[0.5] FiniteOrthogonalFunction_2([0.5, 0.5])=[0.166667] FiniteOrthogonalFunction_3([0.5, 0.5])=[-0.53033] FiniteOrthogonalFunction_4([0.5, 0.5])=[0.0833333] FiniteOrthogonalFunction_5([0.5, 0.5])=[-0.687465]
- __init__(*args)¶
- build(*args)¶
Get the term of the basis collection at a given index or multi-indices.
- Parameters:
- indexint
Indicates the term of the basis which must be constructed. In other words, index is used by a bijection from
to
(with
the dimension of the basis). The bijection is detailed in
EnumerateFunction.- indicessequence of int
Indicates the term of the basis which must be constructed. In other words, indices is used by a bijection from
to
(with
the dimension of the basis). The bijection is the inverse of
EnumerateFunction.
- Returns:
- function
Function The term of the basis collection at the index index or the inverse of indices.
- function
Examples
>>> import openturns as ot >>> # Create an orthogonal basis >>> polynomialCollection = [ot.LegendreFactory(), ot.LaguerreFactory(), ot.HermiteFactory()] >>> productBasis = ot.OrthogonalProductPolynomialFactory(polynomialCollection) >>> termBasis = productBasis.build(4) >>> print(termBasis.getEvaluation()) -1.11803 + 3.3541 * x0^2 >>> termBasis = productBasis.build(5) >>> print(termBasis.getEvaluation()) 1.73205 * x0 * (-1 + x1) >>> termBasis2 = productBasis.build([1, 1, 0]) >>> print(termBasis2.getEvaluation()) 1.73205 * x0 * (-1 + x1)
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getEnumerateFunction()¶
Return the enumerate function.
- Returns:
- enumerateFunction
EnumerateFunction Enumerate function that translates unidimensional indices into multidimensional indices.
- enumerateFunction
- getFunctionsCollection()¶
Accessor to the collection of functions.
- Returns:
- fctColl
FunctionCollection The collection of scalar functions
which defines the basis.
- fctColl
- getInputDimension()¶
Get the input dimension of the Basis.
- Returns:
- inDimint
Input dimension of the functions.
- 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.
- getOutputDimension()¶
Get the output dimension of the Basis.
- Returns:
- outDimint
Output dimension of the functions.
- getSize()¶
Get the size of the Basis.
- Returns:
- sizeint
Size of the Basis.
- 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.
- setFunctionsCollection(functions)¶
Accessor to the collection of functions defining the basis.
- Parameters:
- functionssequence of
Function The collection of functions
.
- .
- functionssequence of
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.
OpenTURNS