{
 "metadata": {
  "name": "stats_arrays demo"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "# stats_arrays demonstration\n",
      "\n",
      "The ``stats_arrays`` library is designed with five main objectives:\n",
      "\n",
      "* Want a consistent interface to SciPy and NumPy statistical function\n",
      "* Want to be able to quickly load and save many parameter uncertainty distribution definitions in a portable format\n",
      "* Want to manipulate and switch parameter uncertainty distributions and variables\n",
      "* Want simple Monte Carlo random number generators that return a vector of parameter values to be fed into uncertainty or sensitivity analysis\n",
      "* Want something simple, extensible, documented and tested\n",
      "\n",
      "Find out more:\n",
      "\n",
      "* Source code: https://bitbucket.org/cmutel/stats_arrays\n",
      "* Online documentation: https://stats_arrays.readthedocs.org/en/latest/"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Defining arrays\n",
      "\n",
      "Let's create a simple array with two uncertain parameters from different uncertainty distributions:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from stats_arrays import *\n",
      "import numpy as np\n",
      "my_variables = UncertaintyBase.from_dicts(\n",
      "    {'loc': 2, 'scale': 0.5, 'uncertainty_type': NormalUncertainty.id},\n",
      "    {'loc': 1.5, 'minimum': 0, 'maximum': 10, 'uncertainty_type': TriangularUncertainty.id}\n",
      ")\n",
      "my_variables"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 1,
       "text": [
        "array([(2.0, 0.5, nan, nan, nan, False, 3),\n",
        "       (1.5, nan, nan, 0.0, 10.0, False, 5)], \n",
        "      dtype=[('loc', '<f8'), ('scale', '<f8'), ('shape', '<f8'), ('minimum', '<f8'), ('maximum', '<f8'), ('negative', '?'), ('uncertainty_type', 'u1')])"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The returned array is a normal NumPy array, and is not wrapped in a class or provided with special functionality. We want the arrays to be quite simple and easy to save and load."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "type(my_variables)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 2,
       "text": [
        "numpy.ndarray"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "One obvious thing that we want to do with uncertain parameters is to sample from their distributions."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "my_rng = MCRandomNumberGenerator(my_variables)\n",
      "for x in range(5):\n",
      "    print my_rng.next()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "[ 1.97593555  0.8728425 ]\n",
        "[ 1.53794138  3.00478287]\n",
        "[ 2.08384221  3.87324292]\n",
        "[ 1.20813909  3.58180859]\n",
        "[ 2.2107861   2.21406803]\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The Monte Carlo RNG can also be an iterator:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "zip(my_rng, xrange(5))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 4,
       "text": [
        "[(array([ 1.66232583,  0.95309365]), 0),\n",
        " (array([ 1.93255217,  0.74483594]), 1),\n",
        " (array([ 2.22056889,  2.41335127]), 2),\n",
        " (array([ 2.2502121 ,  2.29962017]), 3),\n",
        " (array([ 1.33087407,  7.75322672]), 4)]"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Hypercubic sampling\n",
      "\n",
      "We can also sample from a hypercube of parameter values. \n",
      "\n",
      "*Note: that this is not technically Latin sampling, as there is no guarantee that each value is only sampled once*"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lhc = LatinHypercubeRNG(my_variables)\n",
      "lhc.hypercube"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 5,
       "text": [
        "array([[ 1.33241113,  1.54577107,  1.69770733,  1.82562215,  1.94290735,\n",
        "         2.05709265,  2.17437785,  2.30229267,  2.45422893,  2.66758887],\n",
        "       [ 1.16774842,  1.66060826,  2.13754607,  2.64534779,  3.19091516,\n",
        "         3.78418439,  4.44040551,  5.18524994,  6.06877303,  7.22020275]])"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lhc.next()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 6,
       "text": [
        "array([ 1.54577107,  1.66060826])"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Adding bounds\n",
      "\n",
      "We can use the power of NumPy arrays to do some neat things. First, let's get a new array with just Gaussian-distributed variables."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "my_variables = UncertaintyBase.from_dicts(\n",
      "    {'loc': 3, 'scale': 0.5, 'uncertainty_type': NormalUncertainty.id},\n",
      "    {'loc': 4, 'scale': 1, 'uncertainty_type': NormalUncertainty.id},\n",
      "    {'loc': 5, 'scale': 2.5, 'uncertainty_type': NormalUncertainty.id},\n",
      "    {'loc': 6, 'scale': 5, 'uncertainty_type': NormalUncertainty.id},\n",
      ")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "We can then add bounds. Let's exclude values less than zero, and values more than 10 for variables who standard deviation is greater than 2."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "my_variables['minimum'] = 0.\n",
      "mask = my_variables['scale'] > 2\n",
      "my_variables['maximum'][mask] = 10\n",
      "my_variables"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 8,
       "text": [
        "array([(3.0, 0.5, nan, 0.0, nan, False, 3),\n",
        "       (4.0, 1.0, nan, 0.0, nan, False, 3),\n",
        "       (5.0, 2.5, nan, 0.0, 10.0, False, 3),\n",
        "       (6.0, 5.0, nan, 0.0, 10.0, False, 3)], \n",
        "      dtype=[('loc', '<f8'), ('scale', '<f8'), ('shape', '<f8'), ('minimum', '<f8'), ('maximum', '<f8'), ('negative', '?'), ('uncertainty_type', 'u1')])"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "my_rng = MCRandomNumberGenerator(my_variables)\n",
      "some_samples = np.array([my_rng.next() for x in xrange(1000)]).ravel()\n",
      "print (some_samples < 0).sum()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Bounds work throughout ``stats_arrays``, including with hypercubic sampling and with the individual distribution functions described below."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Working with individual distributions\n",
      "\n",
      "There are a number of functions for each uncertainty distribution, e.g. PDF, CDF, PPF."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "ln = UncertaintyBase.from_dicts(\n",
      "    {'loc': 0.2, 'scale': 0.1, 'uncertainty_type': LognormalUncertainty.id}\n",
      ")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 10
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "LognormalUncertainty.statistics(ln)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 11,
       "text": [
        "{'lower': 0.9999999999999998,\n",
        " 'mean': 1.2275250649631777,\n",
        " 'median': 1.2214027581601699,\n",
        " 'mode': 1.2092495976572515,\n",
        " 'upper': 1.4918246976412706}"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "xs = np.linspace(0.5, 2, 100)\n",
      "ys = LognormalUncertainty.cdf(ln, xs.reshape((1, 100)))\n",
      "plot(xs, ys.ravel(), 'g-', lw=2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 12,
       "text": [
        "[<matplotlib.lines.Line2D at 0x1091dc050>]"
       ]
      },
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD9CAYAAABHnDf0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X1YlGWiP/DvwIyAr8iLqTMkyYwMoICGb3k0bDPIF2zV\n9uCmdZQlci/XPNvZattzncXOWS+xPW3+Yuu4VrZpslRWmCntYo4mLmCCYqGIL8SASqIoKsoMw/P7\ng5hEYXibmfuZme/nurhinJuZbzT316d77nkehSRJEoiIyK14iQ5ARET2x3InInJDLHciIjfEcici\nckMsdyIiN8RyJyJyQzbLffny5bjnnnswbty4TsesWrUKOp0OMTExKCkpsXtAIiLqOZvlvmzZMuTm\n5nZ6/65du3Dq1ClUVFTgL3/5C1asWGH3gERE1HM2y3369OkYOnRop/fv2LEDTz31FABg8uTJuHLl\nCmpra+2bkIiIekzZlx+uqalBSEiI9bZGo0F1dTXuueeeduMUCkVfnoaIyGP19iQCfSr3jp64syJ3\nhbMcpKenIz09XXSMLjGn/bhCRkBMTkmSUHW1CiUXSnD84nGUXypH+aVyVF6pxIXrFzr+IQOA+M4f\nUwEF/FR+8FX6wlfpCx9vH/Tz7od+3v2g8lZB5aWC0ktp/fL28oa3whveXt7wUnhBAcVd3yuggEKh\nsP5ZWwfd+b01g0KBkqwSTFg8oX02Gweht/+8M21K2tTrn+1TuavVahiNRuvt6upqqNXqvjwkEQly\n03wTBdUF2PfdPuQb81F8v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Yf5AwD5+fnYunUroqOjMX78eACtS0ZVVVXWrL2Z\nRwpJjot2RETUJ7wSExGRG2K5ExG5IZY7EZEbYrkTEbkhljsRkRtiuRMRuaH/D+YRGXhAF2+1AAAA\nAElFTkSuQmCC\n"
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "xs = np.linspace(0.5, 2, 100)\n",
      "xs, ys = LognormalUncertainty.pdf(ln, xs)\n",
      "plot(xs, ys, 'g-', lw=2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 13,
       "text": [
        "[<matplotlib.lines.Line2D at 0x109011d10>]"
       ]
      },
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD9CAYAAABHnDf0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4VIW9xvHvJDMhmSQkBCQhC2sCZIAsLAYsSwAV2SIt\n1ELVUkXMRS3Qe5+2eutTodfr1ZbnWqyVIlp6gSpWrIo1YAEZkIQkAmHfwpIdAhFCAmSZZM79I85I\nSJiEZGbOLL/P8/BAMidnXiPnzeF3No2iKApCCCE8io/aAYQQQtiflLsQQnggKXchhPBAUu5CCOGB\npNyFEMIDSbkLIYQHslnutbW1pKSkkJSUhMFg4IUXXmixjNFoJCQkhOTkZJKTk3n55ZcdFlYIIUT7\naG296O/vz86dO9Hr9TQ0NDB27Fj27NnD2LFjmy03YcIENm/e7NCgQggh2q/NsYxerwegvr6exsZG\nwsLCWiwj10EJIYRrsbnnDmA2mxk+fDhnz55l0aJFGAyGZq9rNBqysrJITEwkKiqKFStWtLqMEEKI\nu9fhnWelnSorK5WUlBRl586dzT5fVVWl3LhxQ1EURcnIyFDi4uJafO1dvI2qXnrpJbUjtIs75HSH\njIoiOe1NctpXZ7qz3WfLhISEMH36dPbt29fs88HBwdbRzdSpUzGZTFy5cqVjP2mEEELYh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or\nJCUlYTQaOXv2LA888ACHDh0iODjYCQnb7/b/z65aSgA7d+7kL3/5C5mZmWpHacEVtp/2cIXtpz1c\nbfu5fv06c+bMYeXKlQQFBbV4/W63I7uVe3vOid+/fz9z584FoKKigi1btqDT6VqcXulI7ckZExND\njx49CAgIICAggPHjx3Po0CGn/uVsT86srCx+/etfAzBgwAD69evHqVOnGDlypNNytsWdroM4fPgw\nCxcuZOvWrW2OR9TgCttPe7jC9tMerrT9mEwmZs+ezWOPPcasWbNavN6R7chuY5n2nBN/7tw5zp8/\nz/nz55kzZw6rVq1y+l/M9uR8+OGH2bNnD42Njdy8eZOcnBwMBoPL5Rw8eDDbt28HoLy8nFOnTtG/\nf3+n5myLu1wHUVRUxA9+8AM2bNhAbGys2nFa5QrbT3u4wvbTHq6y/SiKwoIFCzAYDCxdurTVZTqy\nHdltz70958S7gvbkHDx4MA899BAJCQn4+PiwcOFCp//lbE/O//zP/+SJJ54gMTERs9nM7373O8LC\nwpyac968eezatYuKigpiYmJYvnw5JpPJmtFVroNoK+dvf/tbrl69ap1n63Q6cnNzXSqjq2grpyts\nP+3J6QrbD0BmZiYbNmwgISGB5ORkoGlkVFRUZM3ake3IKU9iEkII4VzyJCYhhPBAUu5CCOGBpNyF\nEMIDSbkLIYQHknIXQggPJOUuhBAe6P8B97tbOXdTYiUAAAAASUVORK5CYII=\n"
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Defining new distributions\n",
      "\n",
      "It's pretty easy to define a new distribution, especially if you only want to sample from it. See the documentation for the details for how to completely define a new uncertainty distribution."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "\n",
      "\n",
      "class GammaUncertainty(UncertaintyBase):\n",
      "    \"\"\"\n",
      "Gamma distribution.\n",
      "\n",
      "shape : scalar > 0\n",
      "    The shape of the gamma distribution.\n",
      "scale : scalar > 0, optional\n",
      "    The scale of the gamma distribution.  Default is equal to 1.\n",
      "    \"\"\"\n",
      "    id = 99\n",
      "    description = \"Gamma uncertainty\"\n",
      "\n",
      "    @classmethod\n",
      "    def validate(cls, params, transform=False):\n",
      "        return\n",
      "\n",
      "    @classmethod\n",
      "    def random_variables(cls, params, size, seeded_random=None,\n",
      "                         **kwargs):\n",
      "        if not seeded_random:\n",
      "            seeded_random = np.random\n",
      "\n",
      "        data = seeded_random.gamma(\n",
      "            shape=params['shape'],\n",
      "            scale=params['scale'],\n",
      "            size=(size, params.shape[0])).T\n",
      "        data[params['negative'], :] = -1 * data[params['negative'], :]\n",
      "        return data\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 14
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Distributions need to be registered with ``uncertainty_choices``."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "uncertainty_choices.add(GammaUncertainty)\n",
      "print GammaUncertainty in uncertainty_choices"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "True\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "gamma = UncertaintyBase.from_dicts(\n",
      "    {'scale': 0.2, 'shape': 0.5, 'uncertainty_type': GammaUncertainty.id}\n",
      ")\n",
      "rng = MCRandomNumberGenerator(gamma)\n",
      "rng.next()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 16,
       "text": [
        "array([ 0.2103989])"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}