UniVariateDistributionPolynomialFactory

class UniVariateDistributionPolynomialFactory(*args)

Build orthonormal or orthogonal univariate polynomial families.

Warning

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

Parameters:
argDistribution or OrthonormalizationAlgorithm

Either a Distribution implementing the probability measure according to which the polynomial family is orthonormal or an OrthonormalizationAlgorithm.

In the first case, the implementation will switch to the suitable specific orthonormal univariate polynomial family if any (see the notes below), or it will default to the AdaptiveStieltjesAlgorithm to build an orthonormal univariate polynomial family.

Methods

build(degree)

Build the k-th order orthogonal univariate polynomial.

buildRecurrenceCoefficientsCollection(degree)

Build the recurrence coefficients.

getA()

Accessor to the scale coefficient of the affine transformation.

getB()

Accessor to the translation coefficient of the affine transformation.

getClassName()

Accessor to the object's name.

getHasSpecificFamily()

Accessor to the specific family boolean.

getMeasure()

Accessor to the associated probability measure.

getName()

Accessor to the object's name.

getNodesAndWeights(n)

Build the k-th order quadrature scheme.

getOrthonormalizationAlgorithm()

Accessor to the orthonormalization algorithm.

getRecurrenceCoefficients(n)

Accessor to the recurrence coefficients of the k-th order.

getRoots(n)

Accessor to the recurrence coefficients of the k-th order.

getSpecificFamily()

Accessor to the specific orthonormal polynomial family.

hasName()

Test if the object is named.

setName(name)

Accessor to the object's name.

equals

Notes

Use this functionality with caution:

  • The polynomials exist if and only if the distribution admits finite moments of all orders. Otherwise, any result produced will be plain numerical noise.

  • Even if the polynomials exist, they form a Hilbertian basis with respect to the dot product induced by the distribution if and only if the distribution is determinate, i.e., is characterized by its moments. For example, the LogNormal distribution has orthonormal polynomials of arbitrary degree but the projection onto the functional space generated by these polynomials (see FunctionalChaosAlgorithm) may converge to a function that differs significantly from the function being projected (see [ernst2012]). See Functional Chaos Expansion for more details on this topic.

The following specific orthonormal univariate polynomial families are implemented together with their associated distributions.

Distribution

Polynomial

Normal \cN(\mu, \sigma)

HermiteFactory

Uniform \cU(a, b)

LegendreFactory

Gamma \Gamma(k, \lambda, \gamma)

LaguerreFactory

Beta B(\alpha, \beta, a, b)

JacobiFactory

Poisson \cP(\lambda)

CharlierFactory

Binomial \cB(n, p)

KrawtchoukFactory

Polya \cB^-(r, p)

MeixnerFactory

For a distribution which admits a standard representative in the same parametric family, the polynomial family is built for this standard representative. The affine transformation maps a random variable X distributed according to \mu to its standard representative Z = aX + b. For example, if X \sim \cN(\mu, \sigma), its standard representative is Z = (X - \mu)/\sigma \sim \cN(0, 1). The polynomial P_n orthonormal with respect to \mu is the composition of the polynomial p_n orthonormal with respect to the standard representative \mu_0 and of the affine transformation:

P_n(x)\ =\ p_n(a x + b).

Generic algorithms are also implemented for building orthonormal univariate polynomial families with respect to any arbitrary probability measure (implemented as a Distribution). The library implements the following OrthonormalizationAlgorithms, with AdaptiveStieltjesAlgorithm as the default.

Examples

>>> import openturns as ot
>>> import openturns.experimental as otexp

Build the specific orthonormal polynomial factory associated to the normal distribution (Hermite):

>>> polynomial_factory = ot.UniVariateDistributionPolynomialFactory(ot.Normal())
>>> for i in range(3):
...     print(polynomial_factory.build(i))
1
X
-0.707107 + 0.707107 * X^2

Build an orthonormal polynomial factory for the WeibullMin distribution with the default orthonormalization algorithm:

>>> polynomial_factory = ot.UniVariateDistributionPolynomialFactory(ot.WeibullMin())
>>> for i in range(3):
...     print(polynomial_factory.build(i))
1
-1 + X
1 - 2 * X + 0.5 * X^2

Build an orthonormal polynomial factory for the Weibull min distribution with adaptive Stieltjes’s orthonormalization algorithm:

>>> algorithm = ot.AdaptiveStieltjesAlgorithm(ot.WeibullMin())
>>> polynomial_factory = ot.UniVariateDistributionPolynomialFactory(algorithm)
>>> for i in range(3):
...     print(polynomial_factory.build(i))
1
-1 + X
1 - 2 * X + 0.5 * X^2

Non-standard parameters trigger an affine transformation. For example, a Normal distribution with \mu = 2.0 and \sigma = 3.0:

>>> polynomial_factory = ot.UniVariateDistributionPolynomialFactory(ot.Normal(2.0, 3.0))
>>> polynomial_factory.getHasSpecificFamily()
True
__init__(*args)
build(degree)

Build the k-th order orthogonal univariate polynomial.

Parameters:
kint, 0 \leq k

Polynomial order.

Returns:
polynomialOrthogonalUniVariatePolynomial

Requested orthogonal univariate polynomial.

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> print(polynomial_factory.build(2))
-0.707107 + 0.707107 * X^2
buildRecurrenceCoefficientsCollection(degree)

Build the recurrence coefficients.

Build the recurrence coefficients of the orthogonal univariate polynomial family up to the k-th order.

Parameters:
kint, 0 \leq k

Polynomial order.

Returns:
recurrence_coefficientslist of Point

All the tecurrence coefficients up to the requested order.

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> print(polynomial_factory.buildRecurrenceCoefficientsCollection(2))
0 : [  1         0         0        ]
1 : [  0.707107  0        -0.707107 ]
getA()

Accessor to the scale coefficient of the affine transformation.

The affine transformation maps the variable x to the variable z = a x + b: if X is a random variable distributed according to the associated measure, then Z = aX + b is distributed according to its standard representative. The polynomial is evaluated at x as the composition of the polynomial p_n orthonormal with respect to the standard representative and of the affine transformation, i.e. P_n(x) = p_n(a x + b).

Returns:
afloat

The scale coefficient a of the affine transformation.

getB()

Accessor to the translation coefficient of the affine transformation.

The affine transformation maps the variable x to the variable z = a x + b: if X is a random variable distributed according to the associated measure, then Z = aX + b is distributed according to its standard representative. The polynomial is evaluated at x as the composition of the polynomial p_n orthonormal with respect to the standard representative and of the affine transformation, i.e. P_n(x) = p_n(a x + b).

Returns:
bfloat

The translation coefficient b of the affine transformation.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getHasSpecificFamily()

Accessor to the specific family boolean.

Returns:
hasSpecificFamilybool

True if the factory has a specific orthogonal polynomial family.

getMeasure()

Accessor to the associated probability measure.

Returns:
measureDistribution

The associated probability measure (according to which the polynomials are orthogonal).

Notes

Two polynomials P and Q are orthogonal with respect to the probability measure w(x) \di{x} if and only if their dot product:

\langle P, Q \rangle = \int_{\alpha}^{\beta} P(x) Q(x) w(x)\di{x}
                     = 0

where \alpha \in \Rset \cup \{-\infty\} and \beta \in \Rset \cup \{+\infty\}.

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> print(polynomial_factory.getMeasure())
Normal(mu = 0, sigma = 1)
getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getNodesAndWeights(n)

Build the k-th order quadrature scheme.

Associated with the orthogonal univariate polynomials family.

Parameters:
kint, 0 < k

Polynomial order.

Returns:
nodesPoint

The nodes of the k-th order quadrature scheme.

weightsPoint

The weights of the k-th order quadrature scheme.

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> nodes, weights = polynomial_factory.getNodesAndWeights(3)
>>> print(nodes)
[-1.73205,...,1.73205]
>>> print(weights)
[0.166667,0.666667,0.166667]
getOrthonormalizationAlgorithm()

Accessor to the orthonormalization algorithm.

Returns:
orthonormalizationAlgorithmOrthonormalizationAlgorithm

The univariate polynomial orthonormalization algorithm.

getRecurrenceCoefficients(n)

Accessor to the recurrence coefficients of the k-th order.

Of the orthogonal univariate polynomial.

Parameters:
kint, 0 \leq k

Polynomial order.

Returns:
recurrence_coefficientsPoint

The recurrence coefficients of the k-th order orthogonal univariate polynomial.

Notes

Any sequence of orthogonal polynomials has a recurrence formula relating any three consecutive polynomials as follows:

P_{-1}=0, P_0=1, P_{n + 1} = (a_n x + b_n) P_n + c_n P_{n - 1}, \quad n > 1

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> print(polynomial_factory.getRecurrenceCoefficients(3))
[0.5,0,-0.866025]
getRoots(n)

Accessor to the recurrence coefficients of the k-th order.

Of the orthogonal univariate polynomial.

Parameters:
kint, k > 0

Polynomial order.

Returns:
rootsPoint

The roots of the k-th order orthogonal univariate polynomial.

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> print(polynomial_factory.getRoots(3))
[-1.73205,...,1.73205]
getSpecificFamily()

Accessor to the specific orthonormal polynomial family.

Returns:
specificFamilyOrthogonalUniVariatePolynomialFamily

The specific orthonormal univariate polynomial family.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

Examples using the class

FCE: pitfalls due to the input distribution

FCE: pitfalls due to the input distribution