Note
Go to the end to download the full example code
Increase the output dimension of a function¶
Description¶
We want to build a function from q functions .
We can do that:
Case 1: by aggregation of the functions ,
Case 2: by creating a vectorial linear combination of the functions .
Case 1: Aggregation¶
We have functions for . We create the function defined by:
We use the AggregatedFunction
class.
In the example, we take and .
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 functions for . We create the function defined by:
where .
We use the DualLinearCombinationFunction
class.
In the example, we take and .
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])