Conditional expectation of a polynomial chaos expansion

In this example, we compute the conditional expectation of a polynomial chaos expansion of the Ishigami function using the getConditionalExpectation() method.

Introduction

Let \inputDim \in \Nset be the dimension of the input random vector. Let \Expect{\inputRV} \in \Rset^\inputDim be the mean of the input random vector \inputRV. Let \model be the physical model:

\model : \Rset^\inputDim \rightarrow \Rset.

Given \vect{u} \subseteq \{1, ..., \inputDim\} a group of input variables, we want to create a new function \widehat{\model}:

\widehat{\model}: \Rset^{|\vect{u}|} \rightarrow \Rset

where |\vect{u}| = \operatorname{card}(\vect{u}) is the number of variables in the group.

In this example, we experiment two different ways to reduce the input dimension of a polynomial chaos expansion:

  • the parametric function,

  • the conditional expectation.

The goal of this page is to see how we can create these functions and the difference between them.

Parametric function

The simplest method to reduce the dimension of the input is to set some input variables to constant values. In this example, all marginal inputs, except those in the conditioning indices are set to the mean of the input random vector.

Let \overline{\vect{u}} be the complementary set of input marginal indices such that \vect{u} and \overline{\vect{u}} form a disjoint partition of the full set of variable indices:

\vect{u} \; \dot{\cup} \; \overline{\vect{u}} = \{1, ..., \inputDim\}.

The parametric function with reduced dimension is:

\widehat{\model}(\inputReal_{\vect{u}})
= \model\left(\inputReal_{\vect{u}},
         \inputReal_{\overline{\vect{u}}}
         = \Expect{\inputRV_{\overline{\vect{u}}}}\right)

for any \inputReal_{\vect{u}} \in \Rset^{|\vect{u}|}. The previous function is a parametric function based on the function \model where the parameter is \Expect{\inputRV_{\overline{\vect{u}}}}. Assuming that the input random vector has an independent copula, computing \Expect{\inputRV_{\overline{\vect{u}}}} can be done by selecting the corresponding indices in \Expect{\inputRV}. This function can be created using the ParametricFunction class.

Parametric PCE

If the physical model is a PCE, then the associated parametric model is also a PCE. Its coefficients and the associated functional basis can be computed from the original PCE. A significant fact, however, is that the coefficients of the parametric PCE are not the ones of the original PCE: the coefficients of the parametric PCE have to be multiplied by factors which depend on the value of the discarded basis functions on the parameter vector. This feature is not currently available in the library. However, we present it below as this derivation is interesting to understand why the conditional expectation may behave differently from the corresponding parametric PCE.

Let \cJ^P \subseteq \Nset^{\inputDim} be the set of multi-indices corresponding to the truncated polynomial chaos expansion up to the P-th coefficient. Let h be the PCE in the standard space:

h(\standardReal) = \sum_{\vect{\alpha} \in \cJ^P}
    a_{\vect{\alpha}} \psi_{\vect{\alpha}}(\standardReal).

Let \vect{u} \subseteq \{1, ..., \inputDim\} be a group of variables, let \overline{\vect{u}} be its complementary set such that

\vect{u} \; \dot{\cup} \; \overline{\vect{u}} = \{1, ..., \inputDim\}

i.e. the groups \vect{u} and \overline{\vect{u}} create a disjoint partition of the set \{1, ..., \inputDim\}. Let |\vect{u}| \in \Nset be the number of elements in the group \vect{u}. Hence, we have |\vect{u}| + |\overline{\vect{u}}| = \inputDim.

Let \standardReal_{\vect{u}}^{(0)} \in \Rset^{|\vect{u}|} be a given point. We are interested in the function :

\widehat{h}(\standardReal_{\overline{\vect{u}}})
= h\left(\standardReal_{\overline{\vect{u}}},
\standardReal_{\vect{u}}^{(0)}\right)

for any \standardReal_{\overline{\vect{u}}} \in \Rset^{|\overline{\vect{u}}|}. We assume that the polynomial basis are defined by the tensor product:

\psi_{\vect{\alpha}}\left(\standardReal\right)
= \prod_{i = 1}^{\inputDim}
\pi_{\alpha_i}^{(i)}\left(\standardReal\right)

for any \standardReal \in \standardInputSpace where \pi_{\alpha_i}^{(i)} is the polynomial of degree \alpha_i of the i-th input standard variable.

Let \vect{u} = (u_i)_{i = 1, ..., |\vect{u}|} denote the components of the group \vect{u} where |\vect{u}| is the number of elements in the group. Similarly, let \overline{\vect{u}} = (\overline{u}_i)_{i = 1, ..., |\overline{\vect{u}}|} denote the components of the complementary group \overline{\vect{u}}. The components of \standardReal \in \Rset^{\inputDim} which are in the group \vect{u} are \left(z_{u_i}^{(0)}\right)_{i = 1, ..., |\vect{u}|} and the complementary components are \left(z_{\overline{u}_i}\right)_{i = 1, ..., |\overline{\vect{u}}|}.

Let \overline{\psi}_{\overline{\vect{\alpha}}} be the reduced polynomial:

(1)\overline{\psi}_{\overline{\vect{\alpha}}}(z_{\overline{\vect{u}}})
 = \left(\prod_{i = 1}^{|\overline{\vect{u}}|}
    \pi_{\alpha_{\overline{u}_i}}^{(\overline{u}_i)}
    \left(\standardReal_{\overline{u}_i}\right) \right)

where \overline{\vect{\alpha}} \in \Nset^{|\vect{u}|} is the reduced multi-index defined from the multi-index \vect{\alpha}\in \Nset^{\inputDim} by the equation:

\overline{\alpha}_i = \alpha_{\overline{u}_i}

for i = 1, ..., |\overline{\vect{u}}|. The components of the reduced multi-index \overline{\vect{\alpha}} which corresponds to the components of the multi-index given by the complementary group |\vect{u}|.

We must then gather the reduced multi-indices. Let \overline{\cJ}^P be the set of unique reduced multi-indices:

(2)\overline{\cJ}^P = \left\{\overline{\vect{\alpha}} \in \Nset^{|\vect{u}|}
 \; | \; \vect{\alpha} \in \cJ^P\right\}.

For any reduced multi-index \overline{\vect{\alpha}} \in \overline{\cJ}^P of dimension |\overline{\vect{u}}|, we note \cJ_{\overline{\vect{\alpha}}}^P the set of corresponding (un-reduced) multi-indices of dimension \inputDim:

(3)\cJ_{\overline{\vect{\alpha}}}^P
 = \left\{\vect{\alpha} \in \cJ^P \; |\; \overline{\alpha}_i
 = \alpha_{\overline{u}_i}, \; i = 1, ..., |\overline{\vect{u}}|\right\}.

Each aggregated coefficient \overline{a}_{\overline{\vect{\alpha}}} \in \Rset is defined by the equation:

(4)\overline{a}_{\overline{\vect{\alpha}}}
 = \sum_{\vect{\alpha} \in \cJ^P_{\overline{\vect{\alpha}}}}
 a_{\vect{\alpha}} \left(\prod_{i = 1}^{|\vect{u}|}
 \pi_{\alpha_{u_i}}^{(u_i)}\left(\standardReal_{u_i}^{(0)}\right) \right).

Finally:

(5)\widehat{h}(\standardReal_{\overline{\vect{u}}})
 = \sum_{\overline{\vect{\alpha}} \in \overline{\cJ}^P}
 \overline{a}_{\overline{\vect{\alpha}}}
 \overline{\psi}(z_{\overline{\vect{u}}})

for any \standardReal_{\overline{\vect{u}}} \in \Rset^{|\overline{\vect{u}}|}.

The method is the following.

  • Create the reduced polynomial basis from equation (1).

  • Create the list of reduced multi-indices from the equation (2), and, for each reduced multi-index, the list of corresponding multi-indices from the equation (3).

  • Aggregate the coefficients from the equation (4).

  • The parametric PCE is defined by the equation (5).

Conditional expectation

One method to reduce the input dimension of a function is to consider its conditional expectation. The conditional expectation function is:

\widehat{\model}(\inputReal_{\vect{u}})
= \Expect{\model(\inputReal)
         \; | \; \inputRV_{\vect{u}}
         = \inputReal_{\vect{u}}}

for any \inputReal_{\vect{u}} \in \Rset^{|\vect{u}|}. In general, there is no dedicated method to create such a conditional expectation in the library. We can, however, efficiently compute the conditional expectation of a polynomial chaos expansion. In turn, this conditional chaos expansion (PCE) is a polynomial chaos expansion which can be computed using the getConditionalExpectation() method from the FunctionalChaosResult class.

Create the PCE

import openturns as ot
import openturns.viewer as otv
from openturns.usecases import ishigami_function
import matplotlib.pyplot as plt

The next function creates a parametric PCE based on a given PCE and a set of indices.

def meanParametricPCE(chaosResult, indices):
    """
    Return the parametric PCE of Y with given input marginals set to the mean.

    All marginal inputs, except those in the conditioning indices
    are set to the mean of the input random vector.

    The resulting function is :

    g(xu) = PCE(xu, xnotu = E[Xnotu])

    where xu is the input vector of conditioning indices,
    xnotu is the input vector fixed indices and
    E[Xnotu] is the expectation of the random vector of the components
    not in u.

    Parameters
    ----------
    chaosResult: ot.FunctionalChaosResult(inputDimension)
        The polynomial chaos expansion.
    indices: ot.Indices()
        The indices of the input variables which are set to constant values.

    Returns
    -------
    parametricPCEFunction : ot.ParametricFunction(reducedInputDimension, outputDimension)
        The parametric PCE.
        The reducedInputDimension is equal to inputDimension - indices.getSize().
    """
    inputDistribution = chaosResult.getDistribution()
    if not inputDistribution.hasIndependentCopula():
        raise ValueError(
            "The input distribution has a copula" "which is not independent"
        )
    # Create the parametric function
    pceFunction = chaosResult.getMetaModel()
    xMean = inputDistribution.getMean()
    referencePoint = xMean[indices]
    parametricPCEFunction = ot.ParametricFunction(pceFunction, indices, referencePoint)
    return parametricPCEFunction

The next function creates a sparse PCE using least squares.

def computeSparseLeastSquaresFunctionalChaos(
    inputTrain,
    outputTrain,
    multivariateBasis,
    basisSize,
    distribution,
    sparse=True,
):
    """
    Create a sparse polynomial chaos based on least squares.

    * Uses the enumerate rule in multivariateBasis.
    * Uses the LeastSquaresStrategy to compute the coefficients based on
      least squares.
    * Uses LeastSquaresMetaModelSelectionFactory to use the LARS selection method.
    * Uses FixedStrategy in order to keep all the coefficients that the
      LARS method selected.

    Parameters
    ----------
    inputTrain : ot.Sample
        The input design of experiments.
    outputTrain : ot.Sample
        The output design of experiments.
    multivariateBasis : ot.Basis
        The multivariate chaos basis.
    basisSize : int
        The size of the function basis.
    distribution : ot.Distribution.
        The distribution of the input variable.
    sparse: bool
        If True, create a sparse PCE.

    Returns
    -------
    result : ot.PolynomialChaosResult
        The estimated polynomial chaos.
    """
    if sparse:
        selectionAlgorithm = ot.LeastSquaresMetaModelSelectionFactory()
    else:
        selectionAlgorithm = ot.PenalizedLeastSquaresAlgorithmFactory()
    projectionStrategy = ot.LeastSquaresStrategy(
        inputTrain, outputTrain, selectionAlgorithm
    )
    adaptiveStrategy = ot.FixedStrategy(multivariateBasis, basisSize)
    chaosAlgorithm = ot.FunctionalChaosAlgorithm(
        inputTrain, outputTrain, distribution, adaptiveStrategy, projectionStrategy
    )
    chaosAlgorithm.run()
    chaosResult = chaosAlgorithm.getResult()
    return chaosResult

In the next cell, we create a training sample from the Ishigami test function. We choose a sample size equal to 1000.

ot.Log.Show(ot.Log.NONE)
ot.RandomGenerator.SetSeed(0)
im = ishigami_function.IshigamiModel()
input_names = im.inputDistribution.getDescription()
sampleSize = 1000
inputSample = im.inputDistribution.getSample(sampleSize)
outputSample = im.model(inputSample)

We then create a sparce PCE of the Ishigami function using a candidate basis up to the total degree equal to 12. This leads to 455 candidate coefficients. The coefficients are computed from least squares.

multivariateBasis = ot.OrthogonalProductPolynomialFactory([im.X1, im.X2, im.X3])
totalDegree = 12
enumerateFunction = multivariateBasis.getEnumerateFunction()
basisSize = enumerateFunction.getBasisSizeFromTotalDegree(totalDegree)
print("Basis size = ", basisSize)
Basis size =  455

Finally, we create the PCE. Only 61 coefficients are selected by the LARS algorithm.

chaosResult = computeSparseLeastSquaresFunctionalChaos(
    inputSample,
    outputSample,
    multivariateBasis,
    basisSize,
    im.inputDistribution,
)
print("Selected basis size = ", chaosResult.getIndices().getSize())
chaosResult
Selected basis size =  61
FunctionalChaosResult
  • input dimension: 3
  • output dimension: 1
  • distribution dimension: 3
  • transformation: 3 -> 3
  • inverse transformation: 3 -> 3
  • orthogonal basis dimension: 3
  • indices size: 61
  • relative errors: [4.89182e-12]
  • residuals: [7.23589e-06]
Index Multi-index Coeff.
0 [0,0,0] 3.500001
1 [1,0,0] 1.625402
2 [0,2,0] -0.5947211
3 [0,1,1] 2.244114e-05
4 [3,0,0] -1.290657
5 [2,0,1] 1.914665e-05
6 [1,0,2] 1.372414
7 [0,4,0] -1.952288
8 [5,0,0] 0.1949093
9 [3,0,2] -1.089753
10 [1,3,1] -2.098461e-05
11 [1,0,4] 0.409178
12 [0,0,5] -1.356673e-05
13 [3,1,2] 2.218517e-05
14 [0,6,0] 1.357391
15 [0,5,1] 1.855673e-05
16 [7,0,0] -0.01269673
17 [5,0,2] 0.1645622
18 [3,0,4] -0.3249152
19 [1,6,0] 2.081846e-05
20 [0,6,1] -1.670324e-05
21 [0,4,3] 1.955348e-05
22 [0,1,6] -2.26534e-05
23 [8,0,0] -2.0694e-05
24 [7,0,1] -1.31889e-05
25 [3,4,1] 1.171583e-05
26 [3,2,3] -2.385403e-05
27 [3,0,5] -2.743217e-05
28 [2,2,4] -1.903593e-05
29 [1,4,3] -1.483565e-05
30 [0,8,0] -0.3394026
31 [9,0,0] 0.0004335569
32 [7,0,2] -0.01072566
33 [5,0,4] 0.04904866
34 [2,2,5] -1.028609e-05
35 [2,0,7] 2.864731e-05
36 [0,3,6] -3.216074e-05
37 [5,1,4] -1.880647e-05
38 [5,0,5] 5.10031e-06
39 [3,3,4] -1.418323e-05
40 [2,7,1] -2.560594e-05
41 [2,5,3] 2.569984e-05
42 [2,2,6] -1.644522e-05
43 [1,8,1] 1.349855e-05
44 [1,6,3] -1.703189e-05
45 [0,10,0] 0.04590642
46 [0,9,1] 2.539924e-05
47 [0,7,3] -2.121373e-05
48 [11,0,0] -3.13448e-05
49 [9,0,2] 0.0003350317
50 [8,3,0] 8.887562e-06
51 [7,0,4] -0.003227748
52 [2,8,1] -1.699461e-05
53 [1,9,1] -2.116077e-05
54 [0,0,11] -8.784313e-06
55 [6,0,6] 1.656321e-05
56 [3,1,8] -2.322927e-05
57 [2,2,8] 1.572452e-05
58 [1,2,9] 2.925562e-05
59 [0,12,0] -0.003970248
60 [0,0,12] -1.01054e-05


In order to see the structure of the data, we create a grid of plots which shows all projections of Y versus X_i for i = 1, 2, 3. We see that the Ishigami function is particularly non linear.

grid = ot.VisualTest.DrawPairsXY(inputSample, outputSample)
grid.setTitle(f"n = {sampleSize}")
view = otv.View(grid, figure_kw={"figsize": (8.0, 3.0)})
plt.subplots_adjust(wspace=0.4, bottom=0.25)
n = 1000

Parametric function

We now create the parametric function where X_i is free and the other variables are set to their mean values. We can show that a parametric PCE is, again, a PCE. The library does not currently implement this feature. In the next cell, we create it from the meanParametricPCE we defined previously.

Create different parametric functions for the PCE. In the next cell, we create the parametric PCE function where X_1 is active while X_2 and X_3 are set to their mean values.

indices = [1, 2]
parametricPCEFunction = meanParametricPCE(chaosResult, indices)
print(parametricPCEFunction.getInputDimension())
1

Now that we know how the meanParametricPCE works, we loop over the input marginal indices and consider the three functions \widehat{\model}_1(\inputReal_1), \widehat{\model}_2(\inputReal_2) and \widehat{\model}_3(\inputReal_3). For each marginal index i, we we plot the output Y against the input marginal X_i of the sample. Then we plot the parametric function depending on X_i.

inputDimension = im.inputDistribution.getDimension()
npPoints = 100
inputRange = im.inputDistribution.getRange()
inputLowerBound = inputRange.getLowerBound()
inputUpperBound = inputRange.getUpperBound()
# Create the palette with transparency
palette = ot.Drawable().BuildDefaultPalette(2)
firstColor = palette[0]
r, g, b, a = ot.Drawable.ConvertToRGBA(firstColor)
newAlpha = 64
newColor = ot.Drawable.ConvertFromRGBA(r, g, b, newAlpha)
palette[0] = newColor
grid = ot.VisualTest.DrawPairsXY(inputSample, outputSample)
reducedBasisSize = chaosResult.getCoefficients().getSize()
grid.setTitle(
    f"n = {sampleSize}, total degree = {totalDegree}, "
    f"basis = {basisSize}, selected = {reducedBasisSize}"
)
for i in range(inputDimension):
    graph = grid.getGraph(0, i)
    graph.setLegends(["Data"])
    graph.setXTitle(f"$x_{1 + i}$")
    # Set all indices except i
    indices = list(range(inputDimension))
    indices.pop(i)
    parametricPCEFunction = meanParametricPCE(chaosResult, indices)
    xiMin = inputLowerBound[i]
    xiMax = inputUpperBound[i]
    curve = parametricPCEFunction.draw(xiMin, xiMax, npPoints).getDrawable(0)
    curve.setLineWidth(2.0)
    curve.setLegend(r"$PCE(x_i, x_{-i} = \mathbb{E}[X_{-i}])$")
    graph.add(curve)
    if i < inputDimension - 1:
        graph.setLegends([""])
    graph.setColors(palette)
    grid.setGraph(0, i, graph)

grid.setLegendPosition("topright")
view = otv.View(
    grid,
    figure_kw={"figsize": (8.0, 3.0)},
    legend_kw={"bbox_to_anchor": (1.0, 1.0), "loc": "upper left"},
)
plt.subplots_adjust(wspace=0.4, right=0.7, bottom=0.25)
n = 1000, total degree = 12, basis = 455, selected = 61

We see that the parametric function is located within each cloud, but sometimes seems a little vertically on the edges of the data. More precisely, the function represents well how Y depends on X_2, but does not seem to represent well how Y depends on X_1 or X_3.

Conditional expectation

In the next cell, we create the conditional expectation function \Expect{\model(\inputReal) \; | \; \inputRV_1 = \inputReal_1}.

conditionalPCE = chaosResult.getConditionalExpectation([0])
conditionalPCE
FunctionalChaosResult
  • input dimension: 1
  • output dimension: 1
  • distribution dimension: 1
  • transformation: 1 -> 1
  • inverse transformation: 1 -> 1
  • orthogonal basis dimension: 1
  • indices size: 8
  • relative errors: [4.89182e-12]
  • residuals: [7.23589e-06]
Index Multi-index Coeff.
0 [0] 3.500001
1 [1] 1.625402
2 [3] -1.290657
3 [5] 0.1949093
4 [7] -0.01269673
5 [8] -2.0694e-05
6 [9] 0.0004335569
7 [11] -3.13448e-05


On output, we see that the result is, again, a PCE. Moreover, a subset of the previous coefficients are presented in this conditional expectation: only multi-indices which involve X_1 are presented (and the other marginal components are removed). We observe that the value of the coefficients are unchanged with respect to the previous PCE.

In the next cell, we create the conditional expectation function \Expect{\model(\inputReal) \; | \; \inputRV_2 = \inputReal_2, \inputRV_3 = \inputReal_3}.

conditionalPCE = chaosResult.getConditionalExpectation([1, 2])
conditionalPCE
FunctionalChaosResult
  • input dimension: 2
  • output dimension: 1
  • distribution dimension: 2
  • transformation: 2 -> 2
  • inverse transformation: 2 -> 2
  • orthogonal basis dimension: 2
  • indices size: 18
  • relative errors: [4.89182e-12]
  • residuals: [7.23589e-06]
Index Multi-index Coeff.
0 [0,0] 3.500001
1 [2,0] -0.5947211
2 [1,1] 2.244114e-05
3 [4,0] -1.952288
4 [0,5] -1.356673e-05
5 [6,0] 1.357391
6 [5,1] 1.855673e-05
7 [6,1] -1.670324e-05
8 [4,3] 1.955348e-05
9 [1,6] -2.26534e-05
10 [8,0] -0.3394026
11 [3,6] -3.216074e-05
12 [10,0] 0.04590642
13 [9,1] 2.539924e-05
14 [7,3] -2.121373e-05
15 [0,11] -8.784313e-06
16 [12,0] -0.003970248
17 [0,12] -1.01054e-05


We see that the conditional PCE has input dimension 2.

In the next cell, we compare the parametric PCE and the conditional expectation of the PCE.

# sphinx_gallery_thumbnail_number = 3
inputDimension = im.inputDistribution.getDimension()
npPoints = 100
inputRange = im.inputDistribution.getRange()
inputLowerBound = inputRange.getLowerBound()
inputUpperBound = inputRange.getUpperBound()
# Create the palette with transparency
palette = ot.Drawable().BuildDefaultPalette(3)
firstColor = palette[0]
r, g, b, a = ot.Drawable.ConvertToRGBA(firstColor)
newAlpha = 64
newColor = ot.Drawable.ConvertFromRGBA(r, g, b, newAlpha)
palette[0] = newColor
grid = ot.VisualTest.DrawPairsXY(inputSample, outputSample)
grid.setTitle(f"n = {sampleSize}, total degree = {totalDegree}")
for i in range(inputDimension):
    graph = grid.getGraph(0, i)
    graph.setLegends(["Data"])
    graph.setXTitle(f"$x_{1 + i}$")
    xiMin = inputLowerBound[i]
    xiMax = inputUpperBound[i]
    # Set all indices except i to the mean
    indices = list(range(inputDimension))
    indices.pop(i)
    parametricPCEFunction = meanParametricPCE(chaosResult, indices)
    # Draw the parametric function
    curve = parametricPCEFunction.draw(xiMin, xiMax, npPoints).getDrawable(0)
    curve.setLineWidth(2.0)
    curve.setLineStyle("dashed")
    curve.setLegend(r"$PCE\left(x_i, x_{-i} = \mathbb{E}[X_{-i}]\right)$")
    graph.add(curve)
    # Compute conditional expectation given Xi
    conditionalPCE = chaosResult.getConditionalExpectation([i])
    print(f"i = {i}")
    print(conditionalPCE)
    conditionalPCEFunction = conditionalPCE.getMetaModel()
    curve = conditionalPCEFunction.draw(xiMin, xiMax, npPoints).getDrawable(0)
    curve.setLineWidth(2.0)
    curve.setLegend(r"$\mathbb{E}\left[PCE | X_i = x_i\right]$")
    graph.add(curve)
    if i < inputDimension - 1:
        graph.setLegends([""])
    graph.setColors(palette)
    # Set the graph into the grid
    grid.setGraph(0, i, graph)

grid.setLegendPosition("topright")
view = otv.View(
    grid,
    figure_kw={"figsize": (8.0, 3.0)},
    legend_kw={"bbox_to_anchor": (1.0, 1.0), "loc": "upper left"},
)
plt.subplots_adjust(wspace=0.4, right=0.7, bottom=0.25)
n = 1000, total degree = 12
i = 0
FunctionalChaosResult
- input dimension=1
- output dimension=1
- distribution dimension=1
- transformation=1 -> 1
- inverse transformation=1 -> 1
- orthogonal basis dimension=1
- indices size=8
- relative errors=[4.89182e-12]
- residuals=[7.23589e-06]
- is least squares=true
- is model selection=false

| Index | Multi-index   | Coefficient   |
|-------|---------------|---------------|
|     0 | [0]           | 3.5           |
|     1 | [1]           | 1.6254        |
|     2 | [3]           | -1.29066      |
|     3 | [5]           | 0.194909      |
|     4 | [7]           | -0.0126967    |
|     5 | [8]           | -2.0694e-05   |
|     6 | [9]           | 0.000433557   |
|     7 | [11]          | -3.13448e-05  |

i = 1
FunctionalChaosResult
- input dimension=1
- output dimension=1
- distribution dimension=1
- transformation=1 -> 1
- inverse transformation=1 -> 1
- orthogonal basis dimension=1
- indices size=7
- relative errors=[4.89182e-12]
- residuals=[7.23589e-06]
- is least squares=true
- is model selection=false

| Index | Multi-index   | Coefficient   |
|-------|---------------|---------------|
|     0 | [0]           | 3.5           |
|     1 | [2]           | -0.594721     |
|     2 | [4]           | -1.95229      |
|     3 | [6]           | 1.35739       |
|     4 | [8]           | -0.339403     |
|     5 | [10]          | 0.0459064     |
|     6 | [12]          | -0.00397025   |

i = 2
FunctionalChaosResult
- input dimension=1
- output dimension=1
- distribution dimension=1
- transformation=1 -> 1
- inverse transformation=1 -> 1
- orthogonal basis dimension=1
- indices size=4
- relative errors=[4.89182e-12]
- residuals=[7.23589e-06]
- is least squares=true
- is model selection=false

| Index | Multi-index   | Coefficient   |
|-------|---------------|---------------|
|     0 | [0]           | 3.5           |
|     1 | [5]           | -1.35667e-05  |
|     2 | [11]          | -8.78431e-06  |
|     3 | [12]          | -1.01054e-05  |

We see that the conditional expectation of the PCE is a better approximation of the data set than the parametric PCE.

Conclusion

In this example, we have seen how to compute the conditional expectation of a PCE. We have seen that this function is a good approximation of the Ishigami function when we reduce the input dimension. We have also seen that the parametric PCE might be a poor approximation of the Ishigami function. This is because the parametric PCE depends on the particular value that we have chosen to create the parametric function.

The fact that the conditional expectation of the PCE is a good approximation of the function when we reduce the input dimension is a consequence of a theorem which states that the conditional expectation is the best approximation of the function in the least squares sense (see [girardin2018] page 79).

otv.View.ShowAll()

Total running time of the script: (0 minutes 13.816 seconds)