LinearEnumerateFunction

class LinearEnumerateFunction(*args)

Linear enumerate function.

Available constructors:

LinearEnumerateFunction(dim=1)

Parameters
dimint

Dimension.

Notes

Given an input random vector \vect{X} with prescribed probability density function (PDF) f_{\vect{X}}(\vect{x}), it is possible to build up a polynomial chaos (PC) basis \{\psi_{\vect{\alpha}},\vect{\alpha} \in \Nset^{n_X}\}. Of interest is the definition of enumeration strategies for exploring this basis, i.e. of suitable enumeration functions \tau from \Nset to \Nset^{n_X}, which creates a one-to-one mapping between an integer j and a multi-index \Nset^{n_X}.

Let us first define the total degree of any multi-index \vect{\alpha} in \Nset^{n_X} by \sum_{i=1}^{n_X} \alpha_i. A natural choice to sort the PC basis (i.e. the multi-indices \vect{\alpha}) is the lexicographical order with a constraint of increasing total degree. Mathematically speaking, a bijective enumeration function \tau is defined by:

\begin{array}{llcl}
  \tau \, : & \Nset & \longrightarrow & \Nset^{n_X} \\
  &  j & \longmapsto & \{\alpha_1,\dots, \alpha_{n_X}\} \,
             \equiv \, \{\tau_1(j),\dots,\tau_{n_X}(j)\} \\
\end{array}

such that:

\tau(0) = \{0,\dots,0\}

and

\forall 1 \leq j<k  \quad \, , \quad \, \left\{
\begin{array}{l}
  \displaystyle{\sum_{i=1}^{n_X} \tau_i(j) < \sum_{i=1}^{n_X} \tau_i(k)}  \\
  \\
  \mbox{ or} \\
  \\
  \displaystyle{\exists \; m \in \{1,\dots,n_X\} \; : \;
      \left(\forall i \leq m , \; \tau_i(j) = \tau_i(k) \; \right)
      \, \, \, \mbox{ and } \, \, \,
      \left(\tau_m(j) < \tau_m(k) \right)} \\
\end{array}
\right.

Such an enumeration strategy is illustrated in a two-dimensional case (i.e. n_X=2) in the figure below:

(Source code, png, hires.png, pdf)

../../_images/LinearEnumerateFunction.png

This corresponds to the following enumeration of the multi-indices:

j

\vect{\alpha} = \{\alpha_1,\alpha_2\}

0

{0, 0}

1

{1, 0}

2

{0, 1}

3

{2, 0}

4

{1, 1}

5

{0, 2}

6

{3, 0}

7

{2, 1}

8

{1, 2}

9

{0, 3}

Examples

>>> import openturns as ot
>>> # 4-dimensional case
>>> enumerateFunction = ot.LinearEnumerateFunction(4)
>>> for i in range(9):
...     print(enumerateFunction(i))
[0,0,0,0]
[1,0,0,0]
[0,1,0,0]
[0,0,1,0]
[0,0,0,1]
[2,0,0,0]
[1,1,0,0]
[1,0,1,0]
[1,0,0,1]

Methods

__call__(index)

Call self as a function.

getClassName()

Accessor to the object's name.

getDimension()

Return the dimension of the EnumerateFunction.

getId()

Accessor to the object's id.

getMaximumDegreeCardinal(maximumDegree)

Get the cardinal of indices of degree inferior or equal to a given value.

getMaximumDegreeStrataIndex(maximumDegree)

Get the index of the strata of degree inferior to a given value.

getName()

Accessor to the object's name.

getShadowedId()

Accessor to the object's shadowed id.

getStrataCardinal(strataIndex)

Get the number of members of the basis associated to a given strata.

getStrataCumulatedCardinal(strataIndex)

Get the cardinal of the cumulated strata above or equal to the given strata.

getVisibility()

Accessor to the object's visibility state.

hasName()

Test if the object is named.

hasVisibleName()

Test if the object has a distinguishable name.

inverse(indices)

Get the antecedent of a indices list in the EnumerateFunction.

setDimension(dimension)

Set the dimension of the EnumerateFunction.

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)
getClassName()

Accessor to the object’s name.

Returns
class_namestr

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

getDimension()

Return the dimension of the EnumerateFunction.

Returns
dimint, dim \geq 0

Dimension of the EnumerateFunction.

getId()

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getMaximumDegreeCardinal(maximumDegree)

Get the cardinal of indices of degree inferior or equal to a given value.

Parameters
maximumDegreeint

Number of polynoms of the basis.

Returns
cardinalint

Cardinal of indices of degree max \leq maximumDegree.

Examples

>>> import openturns as ot
>>> enumerateFunction = ot.EnumerateFunction(ot.LinearEnumerateFunction(2))
>>> for i in range(6):
...     indices = enumerateFunction(i)
...     degree = sum(indices)
...     print(str(int(degree))+' '+str(indices))
0 [0,0]
1 [1,0]
1 [0,1]
2 [2,0]
2 [1,1]
2 [0,2]
>>> print(enumerateFunction.getMaximumDegreeCardinal(2))
6
getMaximumDegreeStrataIndex(maximumDegree)

Get the index of the strata of degree inferior to a given value.

Parameters
maximumDegreeint

Degree.

Returns
indexint

Index of the strata of degree max \leq maximumDegree.

Examples

>>> import openturns as ot
>>> enumerateFunction = ot.EnumerateFunction(ot.LinearEnumerateFunction(2))
>>> for i in [1, 2]:
...     indices = enumerateFunction(i)
...     strataIndex = sum(indices) + 1
...     print(str(int(strataIndex))+' '+str(indices))
2 [1,0]
2 [0,1]
>>> print(enumerateFunction.getMaximumDegreeStrataIndex(2))
2
getName()

Accessor to the object’s name.

Returns
namestr

The name of the object.

getShadowedId()

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getStrataCardinal(strataIndex)

Get the number of members of the basis associated to a given strata.

Parameters
strataIndexint

Index of the strata in the hierarchical basis. In the context of product of polynomial basis, this is the total polynom degree.

Returns
cardinalint

Number of members of the basis associated to the strata strataIndex. In the context of product of polynomial basis, this is the number of polynoms of the basis which total degree is strataIndex.

Examples

>>> import openturns as ot
>>> enumerateFunction = ot.EnumerateFunction(ot.LinearEnumerateFunction(2))
>>> for i in [3, 4, 5]:
...     indices = enumerateFunction(i)
...     degree = sum(indices)
...     print(str(int(degree))+' '+str(indices))
2 [2,0]
2 [1,1]
2 [0,2]
>>> print(enumerateFunction.getStrataCardinal(2))
3
getStrataCumulatedCardinal(strataIndex)

Get the cardinal of the cumulated strata above or equal to the given strata.

Parameters
strataIndexint

Index of the strata in the hierarchical basis. In the context of product of polynomial basis, this is the total polynomial degree.

Returns
cardinalint

Number of members of the basis associated to the strates inferior or equal to strataIndex. In the context of product of polynomial basis, this is the number of polynomials of the basis which total degree is inferior or equal to strataIndex.

Examples

>>> import openturns as ot
>>> enumerateFunction = ot.EnumerateFunction(ot.LinearEnumerateFunction(2))
>>> for i in range(6):
...     indices = enumerateFunction(i)
...     degree = sum(indices)
...     print(str(int(degree))+' '+str(indices))
0 [0,0]
1 [1,0]
1 [0,1]
2 [2,0]
2 [1,1]
2 [0,2]
>>> print(enumerateFunction.getStrataCumulatedCardinal(2))
6
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.

inverse(indices)

Get the antecedent of a indices list in the EnumerateFunction.

Parameters
multiIndexsequence of int

List of indices.

Returns
antecedentint

Represents the antecedent of the multiIndex in the EnumerateFunction.

Examples

>>> import openturns as ot
>>> enumerateFunction = ot.EnumerateFunction(ot.LinearEnumerateFunction(2))
>>> for i in range(6):
...     print(str(i)+' '+str(enumerateFunction(i)))
0 [0,0]
1 [1,0]
2 [0,1]
3 [2,0]
4 [1,1]
5 [0,2]
>>> print(enumerateFunction.inverse([1,1]))
4
setDimension(dimension)

Set the dimension of the EnumerateFunction.

Parameters
dimint, dim \geq 0

Dimension of the EnumerateFunction.

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.