StandardDistributionPolynomialFactory

class StandardDistributionPolynomialFactory(*args)

Build orthonormal or orthogonal univariate polynomial families.

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.

Notes

Use this functionality with caution:

  • The polynomials exist if and only if the distribution admits finite moments of all orders. Even if some algorithms manage to compute something, it will be plain numerical noise.

  • Even if the polynomials exist, they form an Hilbertian basis wrt the dot product induced by the distribution if and only if the distribution is determinate, ie 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.

OpenTURNS implements the following specific orthonormal 1 univariate polynomial families together with their associated standard distributions:

Standard distribution

Polynomial

Normal \cN(\mu = 0, \sigma = 1)

HermiteFactory

Uniform \cU(a = -1, b = 1)

LegendreFactory

Gamma \Gamma(k = k_a + 1, \lambda = 1, \gamma = 0)

LaguerreFactory

Beta {\rm B}(r = \beta + 1, t = \alpha + \beta + 2, a = -1, b = 1)

JacobiFactory

Poisson \cP(\lambda)

CharlierFactory

Binomial \cB(n, p)

KrawtchoukFactory

NegativeBinomial \cB^-(r, p)

MeixnerFactory

Aside, OpenTURNS also implements generic algorithms for building orthonormal univariate polynomial families with respect to any arbitrary probability measure (implemented as a Distribution). OpenTURNS implements the following OrthonormalizationAlgorithm’s:

1

A polynomial family (P_n)_{n \geq 0} is said to be orthonormal with respect to the probability measure w(x) \di{x} if and only if:

\langle P_i, P_j \rangle = \int_{\supp{w}} P_i(x) P_j(x) w(x) \di{x}
                         = \delta_{ij}, \quad i, j = 1, \ldots, n

where \delta_{ij} denotes Kronecker’s delta.

Examples

>>> import openturns as ot

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

>>> polynomial_factory = ot.StandardDistributionPolynomialFactory(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.StandardDistributionPolynomialFactory(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 log-normal distribution with Chebychev’s othonormalization algorithm:

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

Methods

build(degree)

Build the k-th order orthogonal univariate polynomial.

buildCoefficients(degree)

Build the k-th order orthogonal univariate polynomial coefficients.

buildRecurrenceCoefficientsCollection(degree)

Build the recurrence coefficients.

getClassName()

Accessor to the object's name.

getId()

Accessor to the object's id.

getMeasure()

Accessor to the associated probability measure.

getName()

Accessor to the object's name.

getNodesAndWeights(n)

Build the k-th order quadrature scheme.

getRecurrenceCoefficients(n)

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

getRoots(n)

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

getShadowedId()

Accessor to the object's shadowed id.

getVisibility()

Accessor to the object's visibility state.

hasName()

Test if the object is named.

hasVisibleName()

Test if the object has a distinguishable name.

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)
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
buildCoefficients(degree)

Build the k-th order orthogonal univariate polynomial coefficients.

Parameters
kint, 0 \leq k

Polynomial order.

Returns
coefficientsPoint

Coefficients of the requested orthogonal univariate polynomial.

Examples

>>> import openturns as ot
>>> polynomial_factory = ot.HermiteFactory()
>>> print(polynomial_factory.buildCoefficients(2))
[-0.707107,0,0.707107]
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))
[[1,0,0],[0.707107,0,-0.707107]]
getClassName()

Accessor to the object’s name.

Returns
class_namestr

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

getId()

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

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]
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]
getShadowedId()

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getVisibility()

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

hasName()

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

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

setName(name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.