{ "metadata": { "name": "", "signature": "sha256:bf58fd9edc7de3b2ee6a6950e393b69cd50b266066feeb03e2a99f54689f706d" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to Jupyter\n", "\n", "# Gaussian Process Summer School, Melbourne, Australia\n", "### 25th-27th February 2015\n", "### Neil D. Lawrence\n", "\n", "Welcome to the Jupyter/IPython notebook! We will be using the Jupyter/IPython notebook for all our lab classes and assignments. It is a really convenient way to interact with data using python. This notebook just alllows us to familiarise ourselves with python and Jupyter.\n", "\n", "Python is a generic programming language with 'numerical' and scientific capabilities added on through the numpy and scipy libraries. There are excellent 2-D plotting facilities available through matplotlib. The Jupyter notebook, formerly known as IPython notebook, brings these together in a web based environment that is very convenient for interacting with data.\n", "\n", "In my group we [switched from using MATLAB to Python](http://inverseprobability.com/2013/11/25/gpy-moving-from-matlab-to-python/) a few years ago.\n", "\n", "\n", "## Importing Libraries\n", "\n", "The numpy library provides most of the manipulations we need for arrays in python. numpy is short for numerical python, but as well as providing the numerics, numpy provides contiguous array objects. These objects weren't available in the original python. The first step is to import numpy. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll now use numpy to draw samples from a \"standard normal\". A standard normal is a Gaussian density with mean of zero and variance of one. We'll draw 10 samples from the standard normal. To get help about any command in the notebook simply type that command followed by a question mark." ] }, { "cell_type": "code", "collapsed": false, "input": [ "np.random.normal?" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let's try sampling from the normal distribution." ] }, { "cell_type": "code", "collapsed": false, "input": [ "X = np.random.normal(loc=0, scale=1, size=(10))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let's look at the samples, we can show them using the print command." ] }, { "cell_type": "code", "collapsed": false, "input": [ "print X" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[ 1.0024943 -0.51053385 0.732676 -1.84960139 0.16910256 -2.58423356\n", " 1.68563628 -0.43361129 -0.1625753 -1.38014833]\n" ] } ], "prompt_number": 9 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Estimating Mean and Variance\n", "\n", "We can compute the sample mean by adding all the samples together and dividing by the number of samples." ] }, { "cell_type": "code", "collapsed": false, "input": [ "X.sum()/X.shape[0]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 15, "text": [ "-0.33307945790849203" ] } ], "prompt_number": 15 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Of course we can also estimate the variance, which is easy to write in code as follows" ] }, { "cell_type": "code", "collapsed": false, "input": [ "X.var()" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 13, "text": [ "0.17385733568137476" ] } ], "prompt_number": 13 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Broadcasting\n", "\n", "The numpy array object does not behave like a matrix under multiplication. The * sign means *element by element* multiplication. However, if we construct two matrices as follows and multiply them together., but if we build two matrices and multiply together," ] }, { "cell_type": "code", "collapsed": false, "input": [ "A = np.random.normal(loc=0, scale=1, size=(4, 4))\n", "x = np.random.normal(loc=0, scale=1, size=(4, 1))\n", "print \"A=\", A\n", "print \"x=\", x\n", "print \"A*x=\", A*x" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "A= [[-1.44642403 1.02088569 0.14406612 0.60383246]\n", " [ 0.22158056 -0.94854781 1.09125545 -0.740506 ]\n", " [ 0.06256555 0.95067385 0.59007773 -0.03108409]\n", " [ 0.88536517 0.11283295 -0.69710017 -0.64578467]]\n", "x= [[ 0.75441334]\n", " [-1.30114054]\n", " [ 1.27996971]\n", " [-0.37354737]]\n", "A*x= [[-1.09120159 0.77016979 0.1086854 0.45553926]\n", " [-0.28830745 1.23419402 -1.4198767 0.96350239]\n", " [ 0.08008201 1.21683373 0.75528163 -0.0397867 ]\n", " [-0.33072583 -0.04214845 0.26039993 0.24123116]]\n" ] } ], "prompt_number": 14 }, { "cell_type": "markdown", "metadata": {}, "source": [ "we still get a result even though the dimensions mismatch. This is because of *broadcasting*. Python assumes that we want to multiply *each column* of A by x. This can be convenient, but it can also lead to small bugs. In a lot of mathematical software, if you tried the above operation you'd get a dimension mismatch error." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Lists and Plotting \n", "\n", "If we sample from a standard normal, then the true mean and variance of the distribution should be 0 and 1. Of course, the empirical mean and variance won't match the true mean, but let's use matplotlib to plot the convergence towards that value as we increase the number of samples. To do this we are going to use for loops and python lists. We start by creating empty lists for the means and variances. Then we create a list of integers to iterate through. In Python, a for loop always iterates through a list (in some languages this is called a foreach loop, its counterpart the counter for loop only exists by creating a list of integers, see http://en.wikipedia.org/wiki/Foreach_loop#Python). We can use the range command to create the numbers of samples. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "# create python 'lists' for the samples, means and variances\n", "samples = [10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000] \n", "means = []\n", "variances = []\n", "for n in samples:\n", " x = np.random.normal(loc=0, scale=1, size=(n))\n", " mean = x.mean()\n", " variance = (x**2).mean() - mean**2\n", " means.append(mean)\n", " variances.append(variance)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 14 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plotting in Python\n", "\n", "We'll now plot the variance and the mean against the number of samples. To do this, we need to first convert the samples, varianes and means from Python lists, to numpy arrays." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "\n", "means = np.asarray(means)\n", "variances = np.asarray(variances)\n", "samples = np.asarray(samples)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 15 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we need to include the plotting functionality from matplotlib, and instruct the Jupyter notebook to include the plots *inline* with the notebook, rather than in a different window. First we import the plotting library, matplotlib.\n", "\n", "Here we plot the estimated mean against the number of samples. However, since the samples go up logarithmically it's better to use a logarithmic axis for the $x$-axis, as follows." ] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.semilogx(samples, means)\n", "plt.xlabel('$\\log_{10}n$')\n", "plt.ylabel('mean')" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 17, "text": [ "" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEZCAYAAAC5AHPcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHXZJREFUeJzt3X2UXHWd5/H3hySEB4UQxQRMIAgCBoEEMATkoUAyIkgS\nIuLTDMqZOcLsooxnHYkHzrGd484Ae2bd3eGgrA+kAyIPMeFB0JABCmFwJCBRkEASIJAA6bBAAoEQ\nY/LdP2413TRV3VW3q+rWrfq8zqnTdev+6ta3bzr96fv73d+9igjMzMxqtUPWBZiZWT45QMzMLBUH\niJmZpeIAMTOzVBwgZmaWigPEzMxSyTRAJJ0q6QlJKyVdVGb9wZJ+K+ktSf8tixrNzKy8kVl9sKQR\nwBXAKcDzwFJJt0bE8n7NXga+BszOoEQzMxtElkcg04BVEbE6IrYC1wOz+jeIiJci4iFgaxYFmplZ\nZVkGyAeBNf2W15ZeMzOzHMgyQHwNFTOzHMtsDIRk3GNiv+WJJEchNZPkMDIzSyEilPa9WR6BPAR8\nWNIkSTsCnwNurdB2yG8wIhr6+M53vtPw9w7VbrD1ldYNfL1cu2ratMr+rOV99d6fafZdK+/LZu3P\nWl7vlP3ZjP/r1ey/4crsCCQi/iLpAmAxMAL4SUQsl3Reaf1VksYDS4HdgO2SLgQmR8SmZtdbKBQa\n/t6h2g22vtK6ga+Xazec7y2ttJ9Zy/vqvT+reS1P+7LW96bdn7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"source": [ "We can do the same for the variances, again using a logarithmic axis for the samples. This time, we're going to lavel the x axis using a latex formula." ] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.semilogx(samples, variances)\n", "plt.xlabel('$\\log_{10}n$')\n", "plt.ylabel('variance')" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 18, "text": [ "" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEUCAYAAAAx56EeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHxZJREFUeJzt3XuUFOWd//H3F0QF0egPvAUQvGs25KIGL4gMAoIXFu8o\napQsCS5BzNkkq5vjRnI2m5izq1lgUIkoK2iQn4gS4wVRGcGsirqIF8DAD4abiaAYEQQB5/v74+nR\nZqZnpmemq6uq+/M6p89MV1dXf6do+tNPPVXPY+6OiIhIXW3iLkBERJJJASEiIjkpIEREJCcFhIiI\n5KSAEBGRnBQQIiKS015xF5APM9O5uCIiLeDu1tLnpqYF4e6R3m699dbIn9vUeo093tBjuZbXXdbU\nfe3Pli8rxr5szes053kt3Z96b7ZsvWLsz9ZKTUBEraKiIvLnNrVeY4839Fiu5XWXteZva6k07s/W\nLItaS1+zOc9r6f7Ue7Nl66Vhf1ohUiZqZuZpqDMtxo0bx7hx4+IuoyRoXxaW9mdhmRleDoeYpHDi\n+NZWqrQvC0v7M1nUghARKVFqQYiISCQUECIikpMCQkREclJAlJGaGhgwAJ54Iu5KRCQNFBBlZO5c\nWL0aRoyAefPirkZEkk5nMZWR886Dyy6DY4+Fiy+Ghx+Gvn3jrkpEotLas5gUEGVi5Uo4/XRYuxba\nt4fnn4crroA5c8JyESk9Os1V8nLnnfC974VwADj7bJg2DS68EF5/Pd7aRCSZ1IIoA9u2wRFHhCDo\n0WPPx+bMgVGj4Jln4BvfiKU8EYlIa1sQqRjuW1rnwQehT5/64QAwdCh89hkMHgzPPQcnnlj08kQk\noR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x92XApjZYcC1Wc+93N2f\nBfYxsyOAHZnl5wJPmlnvYvwBIoWgPgiRLGZ2LnA88GvgDDM7FOjk7rdnwuAJM1sLrAFud/d1ZrYk\naxMdMj+3AofxZf/DVqA78HYx/g6RQlBAiGRx96eAwzN359Z5eARwFqFVcDTw78B3M49Z5ufHmZ8H\nAn9198rMdv8YVc0iUVFAiOTvdeB8YBtwCPB7MzuE0OLoBzxAOIzUD6hx97WxVSpSALpQTkREclIn\ntYiI5KSAEBGRnBQQIiKSkwJCRERyUkCIiEhOCggREclJASEiIjkpIEREJCcFhIiI5PT/AUBi7Whe\nI7zCAAAAAElFTkSuQmCC\n", "text": [ "" ] } ], "prompt_number": 18 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Dictionaries\n", "\n", "Lists are one of the standard datatypes in python. They can contain any datatype." ] }, { "cell_type": "code", "collapsed": false, "input": [ "my_list = ['cat', 7, [3, 'dog']]\n", "print(my_list)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "['cat', 7, [3, 'dog']]\n" ] } ], "prompt_number": 20 }, { "cell_type": "markdown", "metadata": {}, "source": [ "For users familiar with java and C++ a list is more akin to a *container* than an array. Python also provides another container-style data type: the dictionary. Dictionaries are similar to lists but they are indexed by text. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "my_dictionary = {'club' : 'Sheffield United', 'stadium' : 'Bramall Lane'}\n", "print(my_dictionary['club'])" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Sheffield United\n" ] } ], "prompt_number": 21 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Naturally the two forms can be combined together and you can have dictionaries that contain lists and lists that contain dictionaries.\n", "\n", "That's it for the moment, but Jupyter and python have a lot to offer, we'll learn more as we go through the other lab sheets." ] } ], "metadata": {} } ] }