{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Create an aggregated function"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this basic example we are going to build a function that stacks all the outputs from several functions\n",
    "\n",
    "$$f = (f_1, \\dots, f_n)$$\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function\n",
    "import openturns as ot\n",
    "import math as m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# assume a list of functions to aggregate\n",
    "functions = list()\n",
    "functions.append(ot.SymbolicFunction(['x1', 'x2', 'x3'],\n",
    "                                     ['x1^2 + x2', 'x1 + x2 + x3']))\n",
    "functions.append(ot.SymbolicFunction(['x1', 'x2', 'x3'],\n",
    "                                     ['x1 + 2 * x2 + x3', 'x1 + x2 - x3']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x= [1.0, 2.0, 3.0] y= [3,6,8,0]\n"
     ]
    }
   ],
   "source": [
    "# create the aggregated function\n",
    "function = ot.AggregatedFunction(functions)\n",
    "x = [1.0, 2.0, 3.0]\n",
    "y = function(x)\n",
    "print('x=', x, 'y=', y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
