OrthogonalProductPolynomialFactory

class OrthogonalProductPolynomialFactory(*args)

Base class for orthogonal multivariate polynomials.

Available constructors:

OrthogonalProductPolynomialFactory(polynomials)

OrthogonalProductPolynomialFactory(polynomials, enumerateFunction)

Parameters:

polynomials : list of OrthogonalUniVariatePolynomialFamily

List of orthogonal univariate polynomials factories with the same dimension as the orthogonal basis.

enumerateFunction : EnumerateFunction

Associates to an integer its multi-index image in the \Nset^d dimension, which is the dimension of the basis. This multi-index represents the collection of degrees of the univariate polynomials.

Notes

OrthogonalProductPolynomialFactory is a particular case of implementation of the OrthogonalBasis in the case of polynomial chaos expansion. It provides to the OrthogonalBasis the persistent types of the univariate orthogonal polynomials (e.g. Hermite, Legendre, Laguerre and Jacobi) needed to determine the distribution measure of projection of the input variable. Let’s note that the exact hessian and gradient have been implemented for the product of polynomials. To facilitate the construction of the basis it is recommanded to use the class StandardDistributionPolynomialFactory.

Examples

>>> import openturns as ot
>>> # Define the model
>>> myModel = ot.SymbolicFunction(['x1','x2','x3'], ['1+x1*x2 + 2*x3^2'])
>>> # Create a distribution of dimension 3
>>> Xdist = ot.ComposedDistribution([ot.Normal(), ot.Uniform(), ot.Gamma(2.75, 1.0)])
>>> # Construct the multivariate orthonormal basis
>>> polyColl = [ot.HermiteFactory(), ot.LegendreFactory(), ot.LaguerreFactory(2.75)]
>>> enumerateFunction = ot.LinearEnumerateFunction(3)
>>> productBasis = ot.OrthogonalProductPolynomialFactory(polyColl, enumerateFunction)
>>> # Easier way to construct the same multivariate orthonormal basis
>>> polyColl = [ot.StandardDistributionPolynomialFactory(Xdist.getMarginal(i)) for i in range(Xdist.getDimension())]
>>> productBasis = ot.OrthogonalProductPolynomialFactory(polyColl, enumerateFunction)

Methods

add(elt) Add an element in the Basis.
build(index) Get the term of the basis collection at a given index.
getClassName() Accessor to the object’s name.
getDimension() Get the dimension of the Basis.
getEnumerateFunction() Return the enumerate function.
getId() Accessor to the object’s id.
getMeasure() Get the measure upon which the basis is orthogonal.
getName() Accessor to the object’s name.
getNodesAndWeights(degrees) Get the nodes and the weights.
getPolynomialFamilyCollection() Get the collection of univariate orthogonal polynomial families.
getShadowedId() Accessor to the object’s shadowed id.
getSize() Get the size of the Basis.
getSubBasis(indices) Get a sub-basis of the Basis.
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
isFunctional() Tell whether the basis is functional.
isOrthogonal() Tell whether the basis is orthogonal.
setName(name) Accessor to the object’s name.
setShadowedId(id) Accessor to the object’s shadowed id.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)
add(elt)

Add an element in the Basis.

Parameters:

function : NumericalMathFunction

Function added in the Basis.

Examples

>>> import openturns as ot
>>> dimension = 3
>>> input = ['x0', 'x1', 'x2']
>>> functions = []
>>> for i in range(2):
...     functions.append(ot.NumericalMathFunction(input, ['y'], [input[i]]))
>>> basis = ot.Basis(functions)
>>> basis.add(ot.NumericalMathFunction(input, ['y'], [input[2]]))
build(index)

Get the term of the basis collection at a given index.

Parameters:

index : int

Indicates the term of the basis which must be constructed. In other words, index is used by a bijection from \Nset to \Nset^d (with d the dimension of the basis). The bijection is detailed in EnumerateFunction.

Returns:

function : NumericalMathFunction

The term of the basis collection at the index index.

Examples

>>> import openturns as ot
>>> # Create an orthogonal basis
>>> polynomialCollection = [ot.LegendreFactory(), ot.LaguerreFactory(), ot.HermiteFactory()]
>>> productBasis = ot.OrthogonalBasis(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)
getClassName()

Accessor to the object’s name.

Returns:

class_name : str

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

getDimension()

Get the dimension of the Basis.

Returns:

dimension : int

Dimension of the Basis.

getEnumerateFunction()

Return the enumerate function.

Returns:

enumerateFunction : EnumerateFunction

Enumerate function that translates unidimensional indices into multidimensional indices.

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getMeasure()

Get the measure upon which the basis is orthogonal.

Returns:

measure : Distribution

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.OrthogonalBasis(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:

name : str

The name of the object.

getNodesAndWeights(degrees)

Get the nodes and the weights.

Parameters:

degrees : list of positiv int (k_1, \dots, k_n)

List of n polynomial orders associated with the n univariate polynomials of the basis.

Returns:

nodes : NumericalSample

weights : NumericalPoint

Nodes and weights of the multivariate polynomial associated with the marginal degrees (k_1, \dots, k_n) as the tensor product of the marginal orthogonal univariate polynomials, to build multivariate quadrature rules.

Examples

>>> import openturns as ot
>>> # Define the model
>>> myModel = ot.SymbolicFunction(['x1','x2','x3'], ['1+x1*x2 + 2*x3^2'])
>>> # Create a distribution of dimension 3
>>> Xdist = ot.ComposedDistribution([ot.Normal(), ot.Uniform(), ot.Gamma(2.75, 1.0)])
>>> # Construct the multivariate orthonormal basis
>>> polyColl = [ot.HermiteFactory(), ot.LegendreFactory(), ot.LaguerreFactory(2.75)]
>>> enumerateFunction = ot.LinearEnumerateFunction(3)
>>> productBasis = ot.OrthogonalProductPolynomialFactory(polyColl, enumerateFunction)
>>> nodes, weights = productBasis.getNodesAndWeights([2, 3, 1])
>>> print(nodes[:2])
    [ v0        v1        v2        ]
0 : [ -1        -0.774597  3.75     ]
1 : [  1        -0.774597  3.75     ]
>>> print(weights[:2])
[0.138889,0.138889]
getPolynomialFamilyCollection()

Get the collection of univariate orthogonal polynomial families.

Returns:

polynomialFamily : list of OrthogonalUniVariatePolynomialFamily

List of orthogonal univariate polynomials families.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getSize()

Get the size of the Basis.

Returns:

size : int

Size of the Basis.

getSubBasis(indices)

Get a sub-basis of the Basis.

Parameters:

indices : list of int

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

Returns:

subBasis : list of NumericalMathFunction

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.NumericalMathFunction(input, ['y'], [input[i]]))
>>> basis = ot.Basis(functions)
>>> subbasis = basis.getSubBasis([1])
>>> print(subbasis[0].getEvaluation())
[x0,x1,x2]->[x1]
getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

isFunctional()

Tell whether the basis is functional.

Returns:

isOrthogonal : bool

True if the basis is functional i.e. if its terms are a solution to an equation (e.g. a basis made up of Legendre functions).

isOrthogonal()

Tell whether the basis is orthogonal.

Returns:

isOrthogonal : bool

True if the basis is orthogonal.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.