Increase the output dimension of a function

Description

We want to build a function f : \mathbb{R}^d \mapsto \mathbb{R}^q from q functions f_i: \mathbb{R}^d \mapsto \mathbb{R}.

We can do that:

  • Case 1: by aggregation of the functions f_i,

  • Case 2: by creating a vectorial linear combination of the functions f_i.

Case 1: Aggregation

We have q functions f_i : \mathbb{R}^d \mapsto \mathbb{R} for 1 \leq i \leq q. We create the function f : \mathbb{R}^d \mapsto \mathbb{R}^q defined by:

f(\vect{x}) =
  \begin{pmatrix}
    f_1(\vect{x}) \\
    \vdots \\
    f_q(\vect{x})
  \end{pmatrix}

We use the AggregatedFunction class.

In the example, we take d=2 and q=3.

import openturns as ot

f1 = ot.SymbolicFunction(['x1', 'x2'], ['x1^2+x2'])
f2 = ot.SymbolicFunction(['x1', 'x2'], ['x1+x2^2'])
f3 = ot.SymbolicFunction(['x1', 'x2'], ['x1+x2'])
func_coll = [f1, f2, f3]
f = ot.AggregatedFunction(func_coll)
print('input dimension =', f.getInputDimension())
print('output dimension =', f.getOutputDimension())
print('f = ', f)
input dimension = 2
output dimension = 3
f =  [[x1,x2]->[x1^2+x2],[x1,x2]->[x1+x2^2],[x1,x2]->[x1+x2]]

Case 2: Vectorial linear combination

We have q functions f_i : \mathbb{R}^d \mapsto \mathbb{R} for 1 \leq i \leq q. We create the function f : \mathbb{R}^d \mapsto \mathbb{R}^q defined by:

f(\vect{x}) = \sum_{i=1}^q \vect{c}_i f_i(\vect{x})

where \vect{c}_i \in \mathbb{R} ^q.

We use the DualLinearCombinationFunction class. In the example, we take d=2 and q=3.

c1 = [2.0, 3.0, 4.0]
c2 = [5.0, 6.0, 7.0]
c3 = [8.0, 9.0, 10.0]
coef_list = [c1, c2, c3]
f = ot.DualLinearCombinationFunction(func_coll, coef_list)
print('input dimension =', f.getInputDimension())
print('output dimension =', f.getOutputDimension())
print('f = ', f)
input dimension = 2
output dimension = 3
f =  [2,3,4] * ([x1,x2]->[x1^2+x2]) + [5,6,7] * ([x1,x2]->[x1+x2^2]) + [8,9,10] * ([x1,x2]->[x1+x2])