diff --git a/Autocorrelation.ipynb b/Autocorrelation.ipynb
new file mode 100644
index 0000000..195ab6b
--- /dev/null
+++ b/Autocorrelation.ipynb
@@ -0,0 +1,258 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Title: Fuzzy sequence matching with cross-correlation\n",
+ "\n",
+ "## Cross-correlation\n",
+ "\n",
+ "I am going to generate a \"random file\" - an array with values ranging between -1 and 1, and then randomly choose a \"random slice\" - a subarray portion from the \"random file\". I'm then going to randomly mutate some of the values in teh subarray, and see if I can still find where in the \"random file\" the \"random slice\" came from."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "import random\n",
+ "import numpy as np\n",
+ "\n",
+ "FILE_SIZE = 100000\n",
+ "SLICE_SIZE = 100\n",
+ "\n",
+ "random_file = np.asarray([random.uniform(-1,1) for i in range(FILE_SIZE)])\n",
+ "random_slice_index = random.randint(0, FILE_SIZE-SLICE_SIZE)\n",
+ "random_slice = random_file[random_slice_index:random_slice_index+SLICE_SIZE]\n",
+ "\n",
+ "# Randomly change the sample by about 50% - simulating a 50% noise\n",
+ "random_slice_mutated = np.asarray([i + random.uniform(-0.5,0.5) for i in random_slice])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "So now, we are going to try to find where in `random_file` the `random_slice_mutated` came from. We know it should be `random_slice_index`.\n",
+ "\n",
+ "### First, let's write our own cross-correlation function to find it."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "# Coding our own cross-correlation algorithm\n",
+ "\n",
+ "def find_sample_index(container, sample):\n",
+ " best_match_index = 0\n",
+ " largest_dot_product = 0\n",
+ " sample_size = len(sample)\n",
+ " for index in range(len(container) - sample_size):\n",
+ " dot = np.dot(container[index:index+sample_size], sample)\n",
+ " if dot > largest_dot_product:\n",
+ " best_match_index = index\n",
+ " largest_dot_product = dot\n",
+ " return (best_match_index, largest_dot_product)\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(14108, 33.238798044766)"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "find_sample_index(random_file, random_slice_mutated)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Actual index (should match): 14108\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"Actual index (should match):\", random_slice_index)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Now, let's use the `scipy.signal.correlate()` function instead of our own one.\n",
+ "\n",
+ "Note that the numpy implementation returns a vector of all of the correlation values, not just the largest one, so to find the largest index, we need to find the largest value."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "14108"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import scipy.signal\n",
+ "result = scipy.signal.correlate(random_file, random_slice)\n",
+ "max_correlation_index = np.argmax(result) - (SLICE_SIZE-1)\n",
+ "max_correlation_index"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Cross-correlation algorithm"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 3, 8, 14, 20, 26, 14, 5])"
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "a = np.array([1,2,3,4,5])\n",
+ "b = np.array([1,2,3])\n",
+ "scipy.signal.correlate(a,b)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "For vectors:\n",
+ "\n",
+ "A=\n",
+ "
\n",
+ "\n",
+ "B=\n",
+ "\n",
+ "\n",
+ "The cross-correlate algorithm zero-pads each vector as such (where the blank cells represent 0):\n",
+ "\n",
+ "#### Step 1\n",
+ "\n",
+ " | | 1 | 2 | 3 | 4 | 5 |
\n",
+ "1 | 2 | 3 | | | | |
\n",
+ "
\n",
+ "\n",
+ " 0*1 + 0*2 + 1*3 + 2*0 + 3*0 + 4*0 + 5*0 = 3\n",
+ "\n",
+ "#### Step 2\n",
+ "\n",
+ " | 1 | 2 | 3 | 4 | 5 |
\n",
+ "1 | 2 | 3 | | | |
\n",
+ "
\n",
+ "\n",
+ " 0*1 + 1*2 + 2*3 + 3*0 + 4*0 + 5*0 = 8\n",
+ "\n",
+ "#### Step 3\n",
+ "\n",
+ "1 | 2 | 3 | 4 | 5 |
\n",
+ "1 | 2 | 3 | | |
\n",
+ "
\n",
+ "\n",
+ " 1*1 + 2*2 + 3*3 + 4*0 + 5*0 = 14\n",
+ "\n",
+ "## ...\n",
+ "\n",
+ "#### Last step\n",
+ "\n",
+ "1 | 2 | 3 | 4 | 5 | | |
\n",
+ " | | | | 1 | 2 | 3 |
\n",
+ "
\n",
+ "\n",
+ "So each step consists of doing the appropriate zero-padding and taking the dot product of the 2 vectors, and then moving to the right one spot."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "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.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/ExpectedValue.ipynb b/ExpectedValue.ipynb
new file mode 100644
index 0000000..6bfe5ff
--- /dev/null
+++ b/ExpectedValue.ipynb
@@ -0,0 +1,191 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "values = [1]*10 + [5]*1000 + [10000]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Median"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "5"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "median = values[len(values)//2]\n",
+ "median"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Mode"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Counter({1: 10, 5: 1000, 10000: 1})"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import collections\n",
+ "counts = collections.Counter(values)\n",
+ "counts"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "5"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "mode = counts.most_common()[0][0]\n",
+ "mode"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Mean/average"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "14.846686449060336"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "average = sum(values) / len(values)\n",
+ "average"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Expected Value\n",
+ "\n",
+ "The Expected Value is the same as the Mean, but I'm calculating it in a probabilistic way to show they are the same"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "14.846686449060336"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "expected_value = 1 * (10/len(values)) + 5 * (1000/len(values)) + 10000 * (1/len(values))\n",
+ "expected_value"
+ ]
+ },
+ {
+ "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.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/PoissonDistribution.ipynb b/PoissonDistribution.ipynb
new file mode 100644
index 0000000..0af3c51
--- /dev/null
+++ b/PoissonDistribution.ipynb
@@ -0,0 +1,253 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Poisson Distribution\n",
+ "\n",
+ "probability density function: \n",
+ "\n",
+ "\\begin{equation}\n",
+ "\\frac{\\lambda^k e^{-\\lambda}}{k!}\n",
+ "\\end{equation}\n",
+ "\n",
+ "mean:\n",
+ "\\begin{equation}\n",
+ "\\lambda\n",
+ "\\end{equation}\n",
+ "\n",
+ "variance:\n",
+ "\\begin{equation}\n",
+ "\\lambda\n",
+ "\\end{equation}\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "import math\n",
+ "import numpy as np\n",
+ "import scipy.stats as stats\n",
+ "import pandas as pd\n",
+ "import matplotlib.pyplot as plt\n",
+ "%matplotlib inline"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Discrete pmf"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEACAYAAABfxaZOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFC1JREFUeJzt3W2snOWd3/Hvz3KBgiHZZFmi2jHLw8Z0aXhIV15asukk\naIM3q8WR9kVNqk2XCoSqkERN1bJLtQqWKpTSVtVuabq4sNEmIiVtUsAvCJg0O2ppRGJSYBPWDs4T\naxtDw1OARDi2+ffFjJ3hcOy5j8+cM8e+vh/pyPfDdV3zP+d4fnOfa+577lQVkqQ2LJt2AZKkxWPo\nS1JDDH1JaoihL0kNMfQlqSGGviQ1pFPoJ1mXZHuSJ5JcP8v+K5I8luSRJA8ned/Ivh+O7PvGJIuX\nJM1Nxp2nn2QZ8ARwGfAUsBXYUFXbR9qcXFU/HS6/E7irqs4drn8f+LtV9cLCfAuSp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6pN5t5419zm4HfHy7/Y2ApHJy8rsYk6xhMP15R\nVXunVtUbHaqzqr5dVW+rqrOr6iwGBykXV9VSeBGd+Tu/G3gfwPD59Deq6rkjDTDV0B8eQR28eOtx\n4M6lePFWkkuBfwS8L8kjw3noddOu6xj3MeCOJI8yOHvnpinX8zpV9RiDT479JvAYgyfapqkWNSLJ\n54GvAe9I8tdJrgI+Bfxmku8weJEae/reFGr8j8AK4IHh8+jT06wRDlvnqGIJTO8cps4/A85O8i3g\n88DYgzwvzpKkhkx7ekeStIgMfUlqiKEvSQ0x9CWpIYa+JDXE0Jekhhj6ktQQQ1+SGvL/AaWXPcuX\ndGdWAAAAAElFTkSuQmCC\n",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "a = range(16)\n",
+ "lambda1 = 1.5\n",
+ "\n",
+ "plt.bar(a, stats.poisson.pmf(a, lambda1), color=\"#348ABD\",\n",
+ " label=\"$\\lambda = %.1f$\" % lambda1, alpha=0.60,\n",
+ " edgecolor=\"#348ABD\", lw=\"3\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Continuous pdf"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEACAYAAABI5zaHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUXGd55/HvU0vvu6TW0q1dlrxLNrYs22AMhiCYg01W\n7CwTHBIcEkMmycmYbAPnZBYnYRKSOA44AwwQjByWgIdgULBpg2xsy9bmRbtkSa21W2r1ol6r6pk/\nqlRd3epd1X2rqn+fc+ro3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+BdwWcE1jOW1m8wHMbAFwJuB6RmVmHyLZfZirH5YrgWXA\nTjM7TDKXXjGzXPxr6BjJn03cfSuQMLM5Y71gpsI9fSFUaiTCvSQvfMpFXwDecPe/C7qQkbj7n7j7\nEndfQfLr+Iy7/+eg6xou1XVwzMxWpzbdRW6eAN4LbDCzEktO6nEXuXXid/hfZ08CH0ot/zqQKw2Q\nIXWmpgliNRP8AAAA7klEQVT/I+Bud+8LrKpLpet099fcfYG7r3D35SQbJDe4ey58YA7/vn8beCdA\n6ncq6u5nxzrAjIR7qkV08UKo14FN7p5Lv0AAmNntwK8A7zSz7am+4o1B15XHPg581cx2kBwt8z8D\nrucS7r6T5IymrwA7Sf5CPRZoUSlm9jjwPLDazI6a2f3Aw8C7zWwvyQ+icYfETbdR6vwHoAL4j9Tv\n0aOBFsmodWZycqBbZpQ6vwCsMLNXgceBcRt0uohJRKQA6YSqiEgBUriLiBQghbuISAFSuIuIFCCF\nu4hIAVK4i4gUIIW7iEgBUriLiBSg/w8ReQZ4gAYWLgAAAABJRU5ErkJggg==\n",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "a = np.linspace(0, 16, 100)\n",
+ "lambda1 = 0.5\n",
+ "plt.plot(a, stats.expon.pdf(a, scale=1/lambda1), lw=3,\n",
+ " color=\"#348ABD\", label=\"$\\lambda = %.1f$\" % lambda1)\n",
+ "plt.fill_between(a, stats.expon.pdf(a, scale=1/lambda1), color=\"#348ABD\", alpha=.33)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "def poisson(lamb, k):\n",
+ " return (lamb**k * math.e**(-1*k)) / math.factorial(k)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "0.02800522595692347"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "poisson(1.5, 3)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAEDCAYAAADDbTRuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEkVJREFUeJzt3X2wXHV9x/H3N0QSIiQ8KWAiyIOQDiNP0pSpjFy1NRda\njbVMBWZ8oJZhpk11pp2K4nQIHY3oqOMoRQlm6GhL4wO1YitJqrJSrQKWJIDeK49CbgwISgioSZP4\n7R/nJG4292HvuRtyfzfv18xOzvmd3373e/fu/ezZc3Y3kZlIkso0bV83IElqzhCXpIIZ4pJUMENc\nkgpmiEtSwQxxSSrYmCEeEcsj4omIuGeUOZ+MiAciYm1EnNHbFiVJI+lmT/xGYOFIGyPifODEzHw5\ncDnwmR71Jkkaw5ghnpnfAZ4eZcoi4HP13DuAORFxVG/akySNphfHxOcC69vWN9RjkqS9zBObklSw\n6T2osQF4adv6vHpsDxHhF7VIUgOZGcONd7snHvVlOLcAbwOIiHOATZn5xCiN7Lp8cOUAi7+4hgs/\n+709Lr/zhnfuMbb4i2v44MqB3WqM53LVVVc1vu7zVbOEHq1pTWs+vzVHM+aeeETcBPQBR0TEY8BV\nwIFVHueyzPx6RFwQEQ8CvwQuHavmcM6cd+hu67+YPXO3sTVDm5qUlaQpbcwQz8xLupizuDftSJLG\nY9Ke2Dz+tAU9r9nX1zfpa5bQozWtac3JUzPGOt7SSxGR7be3dNUgGzdv4fHNW/Y4nNJpzdAmjp49\nk2Nmz+TKhfP3dquSNGlEBDnBE5uSpEnIEJekghniklQwQ1ySCm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3uGzCHhxPfwE1VdiXJOZTzeoeSFVCP54mG1vysx/\nb1DzI8DqzPxGx3g/8Kms/k+C8db8B+Aj2faOsXr8JKqf/cLx1uyo80bgSuBlmXn0BOpc1TF0XWY+\nGRFHU/Xf6B1khrg0xTV5N5Y196hzENV/fHPfZOvTEJemuIh4LDOPtebUrDkpPuwjaWIi4p6RNtHs\n3VjWLKAmGOLSVHEU1f+D23nsO4D/seaUrWmIS1PEf1B9GG1t54aIaFlzytb0mLgklWwyfGJTktSQ\nIS5JBTPEJalghrgkFcwQl6SC/T+HcqrQCNdRMAAAAABJRU5ErkJggg==\n",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "x = range(16)\n",
+ "prob = [poisson(1.5, i) for i in x]\n",
+ "\n",
+ "pd.Series(prob, index=x).plot(kind='bar', lw=3,\n",
+ " color=\"#348ABD\", alpha=0.60,\n",
+ " edgecolor=\"#348ABD\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "np.arange(16)"
+ ]
+ },
+ {
+ "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.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/genetic_algorithm.ipynb b/genetic_algorithm.ipynb
new file mode 100644
index 0000000..6066d51
--- /dev/null
+++ b/genetic_algorithm.ipynb
@@ -0,0 +1,549 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Genetic Algorithm\n",
+ "\n",
+ "The genetic algorithm emulates Evolution by \"breeding\" solutions from previous solutions and applying mutation. The likelihood that a solution \"survives\" is based on its \"fitness\" value (as defined by some \"fitness function\").\n",
+ "\n",
+ "### Problem to solve\n",
+ "\n",
+ "Let's try using it to solve a simple equation:\n",
+ "\n",
+ "* x − y = −1\n",
+ "* 3x + y = 9\n",
+ "\n",
+ "**(The real solution is x=2, y=3)**\n",
+ "\n",
+ "## Generic Genetic Algorithm\n",
+ "\n",
+ "First, let's write a basic genetic algorithm.\n",
+ "\n",
+ "Each \"individual\" will be a list in this form: [fitness, val1, val2, ...]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 68,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "import random\n",
+ "\n",
+ "def generate_couples(population):\n",
+ " couples = []\n",
+ " for i in range(0, len(population)-1, 2):\n",
+ " c = (population[i], population[i+1])\n",
+ " couples.append(c)\n",
+ " return couples\n",
+ "\n",
+ "def genetic_algorithm(fit_func, cross_func, mutate_func, init_pop, max_iter=1000,\n",
+ " max_pop=100, quit_at_err=0.01, mut_prob=0.1, mut_mu=0, mut_sigma=1):\n",
+ " population = init_pop\n",
+ " num_solutions_considered = 0\n",
+ " top_dog = init_pop[0]\n",
+ " \n",
+ " for i in range(max_iter): \n",
+ " # Calculate fitness function for each individual\n",
+ " for individual in population:\n",
+ " fitness = individual[0]\n",
+ " if fitness < 0: # Meaning it has not been calculated, since fitness is always positive or 0\n",
+ " fitness = fit_func(individual)\n",
+ " individual[0] = fitness\n",
+ "\n",
+ " # Sort population by fitness\n",
+ " population.sort()\n",
+ " top_dog = population[0]\n",
+ " num_solutions_considered += len(population)\n",
+ " if top_dog[0] < quit_at_err:\n",
+ " print('Generations: {}, Solutions considered: {}'.format(i, num_solutions_considered))\n",
+ " return top_dog\n",
+ " \n",
+ " # Make couples\n",
+ " couples = generate_couples(population)\n",
+ " \n",
+ " # Mate\n",
+ " babies = [mutate(have_sex(couple[0], couple[1]), mut_prob, mut_mu, mut_sigma) for couple in couples]\n",
+ " population += babies\n",
+ " \n",
+ " # Sort and cull\n",
+ " population.sort()\n",
+ " population = population[:max_pop]\n",
+ " \n",
+ " #print('Iteration {}, Population: {}'.format(i, len(population)))\n",
+ "\n",
+ " print('Generations: {}, Solutions considered: {}'.format(i, num_solutions_considered))\n",
+ " return top_dog\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Write problem-specific functions"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 51,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Iterations: 39, # solutions considered: 3183\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "[0.0003454095730006291, 1.995886744141802, 3.01436163580238]"
+ ]
+ },
+ "execution_count": 51,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "def fitness_function(individual):\n",
+ " fitness, x, y = individual\n",
+ " # We square the error so it's always positive\n",
+ " eq1_error = ((x - y) - (-1))**2\n",
+ " eq2_error = ((3*x + y) - 9)**2\n",
+ " return eq1_error + eq2_error\n",
+ "\n",
+ "def have_sex(a, b):\n",
+ " x = a[1]\n",
+ " y = b[2]\n",
+ " return [-1, x, y]\n",
+ "\n",
+ "def mutate(a, mutation_probability, mu, sigma):\n",
+ " mutant = [-1]\n",
+ " for var in a[1:]:\n",
+ " if random.random() <= mutation_probability:\n",
+ " new_var = var + random.gauss(mu, sigma)\n",
+ " mutant.append(new_var)\n",
+ " else:\n",
+ " mutant.append(var)\n",
+ " return mutant\n",
+ "\n",
+ "initial_population = [[-1, 0, 0], [-1, 10, 10]] \n",
+ "most_fit_solution = genetic_algorithm(fitness_function, have_sex, mutate, initial_population)\n",
+ "most_fit_solution"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "**Wow, so that's a pretty close solution in not too many generations (or solutions considered).**\n",
+ "\n",
+ "Now, let's compare it these 2 types of random searches:\n",
+ "\n",
+ "* Random walk\n",
+ "* Uniform random search (in a constrained window)\n",
+ "\n",
+ "## Comparison with random walk solution"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Iteration: 0, Error: 58.197997727493785\n",
+ "Iteration: 10000, Error: 44847.096572963936\n",
+ "Iteration: 20000, Error: 26046.67741968994\n",
+ "Iteration: 30000, Error: 188915.547005843\n",
+ "Iteration: 40000, Error: 179066.1641331165\n",
+ "Iteration: 50000, Error: 98354.59650722975\n",
+ "Iteration: 60000, Error: 8099.110689885708\n",
+ "Iteration: 70000, Error: 22889.705969310067\n",
+ "Iteration: 80000, Error: 78947.95786648008\n",
+ "Iteration: 90000, Error: 81609.08510716847\n",
+ "Iteration: 100000, Error: 88042.48735877528\n",
+ "Iteration: 110000, Error: 127779.6609447398\n",
+ "Iteration: 120000, Error: 132049.4104383309\n",
+ "Iteration: 130000, Error: 30637.002742822388\n",
+ "Iteration: 140000, Error: 3029.9929598023473\n",
+ "Iteration: 150000, Error: 7267.082706040252\n",
+ "Iteration: 160000, Error: 12265.728575374562\n",
+ "Iteration: 170000, Error: 51693.022768068826\n",
+ "Iteration: 180000, Error: 54654.50564500899\n",
+ "Iteration: 190000, Error: 214919.2574790537\n",
+ "Iteration: 200000, Error: 233639.1235252252\n",
+ "Iteration: 210000, Error: 487713.4435635344\n",
+ "Iteration: 220000, Error: 308793.3769138881\n",
+ "Iteration: 230000, Error: 191308.4797177279\n",
+ "Iteration: 240000, Error: 170588.67097886262\n",
+ "Iteration: 250000, Error: 216560.60255446262\n",
+ "Iteration: 260000, Error: 267419.4993022812\n",
+ "Iteration: 270000, Error: 196970.79306162673\n",
+ "Iteration: 280000, Error: 137246.13771499082\n",
+ "Iteration: 290000, Error: 234730.14229765147\n",
+ "Iteration: 300000, Error: 316515.73946372623\n",
+ "Iteration: 310000, Error: 96594.69180194367\n",
+ "Iteration: 320000, Error: 130340.22848921012\n",
+ "Iteration: 330000, Error: 238135.03138638474\n",
+ "Iteration: 340000, Error: 178144.2447365376\n",
+ "Iteration: 350000, Error: 91122.51122254215\n",
+ "Iteration: 360000, Error: 129037.17506907361\n",
+ "Iteration: 370000, Error: 94361.99443001603\n",
+ "Iteration: 380000, Error: 71590.15927380601\n",
+ "Iteration: 390000, Error: 113332.32090784302\n",
+ "Iteration: 400000, Error: 82939.92711723235\n",
+ "Iteration: 410000, Error: 102994.44479207975\n",
+ "Iteration: 420000, Error: 167350.32331303938\n",
+ "Iteration: 430000, Error: 266967.33455625275\n",
+ "Iteration: 440000, Error: 322675.2160211878\n",
+ "Iteration: 450000, Error: 265426.0888841365\n",
+ "Iteration: 460000, Error: 95414.11415708082\n",
+ "Iteration: 470000, Error: 110365.3236887952\n",
+ "Iteration: 480000, Error: 214668.19020671965\n",
+ "Iteration: 490000, Error: 395312.02751460485\n",
+ "Iteration: 500000, Error: 661233.0135322829\n",
+ "Iteration: 510000, Error: 727568.1860427626\n",
+ "Iteration: 520000, Error: 543812.1712617927\n",
+ "Iteration: 530000, Error: 619007.9935390004\n",
+ "Iteration: 540000, Error: 597298.2276811234\n",
+ "Iteration: 550000, Error: 428322.09524126496\n",
+ "Iteration: 560000, Error: 609866.003075995\n",
+ "Iteration: 570000, Error: 745286.954889121\n",
+ "Iteration: 580000, Error: 852618.3208857924\n",
+ "Iteration: 590000, Error: 605701.2808994589\n",
+ "Iteration: 600000, Error: 751782.2243780773\n",
+ "Iteration: 610000, Error: 1285479.4597460038\n",
+ "Iteration: 620000, Error: 989334.980567904\n",
+ "Iteration: 630000, Error: 1337629.770909281\n",
+ "Iteration: 640000, Error: 1331822.0997493195\n",
+ "Iteration: 650000, Error: 1182752.318036363\n",
+ "Iteration: 660000, Error: 1643215.6954800738\n",
+ "Iteration: 670000, Error: 1564810.9477126657\n",
+ "Iteration: 680000, Error: 1629185.869107097\n",
+ "Iteration: 690000, Error: 2117395.143278152\n",
+ "Iteration: 700000, Error: 1648325.8893040004\n",
+ "Iteration: 710000, Error: 1782785.121202516\n",
+ "Iteration: 720000, Error: 1911100.8238497002\n",
+ "Iteration: 730000, Error: 1768831.9622492203\n",
+ "Iteration: 740000, Error: 1378838.7785962422\n",
+ "Iteration: 750000, Error: 1625563.5905535538\n",
+ "Iteration: 760000, Error: 1879327.6407330749\n",
+ "Iteration: 770000, Error: 1691495.5339371949\n",
+ "Iteration: 780000, Error: 1763827.414770319\n",
+ "Iteration: 790000, Error: 2626745.5558397365\n",
+ "Iteration: 800000, Error: 2390306.5618254687\n",
+ "Iteration: 810000, Error: 2264505.8102024305\n",
+ "Iteration: 820000, Error: 2431449.0096305464\n",
+ "Iteration: 830000, Error: 1461922.5381285502\n",
+ "Iteration: 840000, Error: 1815617.8344376218\n",
+ "Iteration: 850000, Error: 2624923.3861788064\n",
+ "Iteration: 860000, Error: 2696485.3145767944\n",
+ "Iteration: 870000, Error: 2386429.2533477843\n",
+ "Iteration: 880000, Error: 2416684.968660689\n",
+ "Iteration: 890000, Error: 1814027.4063623594\n",
+ "Iteration: 900000, Error: 1828885.0829097293\n",
+ "Iteration: 910000, Error: 1433186.612471411\n",
+ "Iteration: 920000, Error: 1316005.8469770257\n",
+ "Iteration: 930000, Error: 1152410.0941889544\n",
+ "Iteration: 940000, Error: 863993.5984905271\n",
+ "Iteration: 950000, Error: 844028.4266753952\n",
+ "Iteration: 960000, Error: 946837.0578228715\n",
+ "Iteration: 970000, Error: 955333.4077869634\n",
+ "Iteration: 980000, Error: 1078488.3699869053\n",
+ "Iteration: 990000, Error: 939357.1692977182\n",
+ "Iteration: 1000000, Error: 949823.6069154186\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "[-215.50760466522127, 754.9920021071864]"
+ ]
+ },
+ "execution_count": 65,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "def random_walk_next_solution(prev_solution, mu, sigma):\n",
+ " return [prev_solution[0] + random.gauss(mu, sigma), prev_solution[1] + random.gauss(mu, sigma)]\n",
+ "\n",
+ "def error_function(individual):\n",
+ " x, y = individual\n",
+ " # We square the error so it's always positive\n",
+ " eq1_error = ((x - y) - (-1))**2\n",
+ " eq2_error = ((3*x + y) - 9)**2\n",
+ " return eq1_error + eq2_error\n",
+ "\n",
+ "def do_random_walk_search(mu, sigma, init_guess, max_iter=100*10000+1, quit_at_err=0.01):\n",
+ " current_solution = init_guess\n",
+ " \n",
+ " for i in range(max_iter):\n",
+ " current_solution = random_walk_next_solution(current_solution, 0, .5)\n",
+ " current_solution_err = error_function(current_solution)\n",
+ " if current_solution_err < quit_at_err:\n",
+ " print('Solutions considered: {}, Error: {}'.format(i, current_solution_err))\n",
+ " break\n",
+ " if i % 10000 == 0:\n",
+ " print('Iteration: {}, Error: {}'.format(i, current_solution_err))\n",
+ " \n",
+ " return current_solution\n",
+ "\n",
+ "do_random_walk_search(0, 0.5, [0, 0])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "That is a pretty bad solution, and a ton of error.\n",
+ "\n",
+ "## Comparison with random (non-walk) solution"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 66,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Iteration: 0, Error: 308.3127928505571\n",
+ "Iteration: 10000, Error: 4727.309365030706\n",
+ "Iteration: 20000, Error: 2702.1996692573516\n",
+ "Iteration: 30000, Error: 295.37602816058853\n",
+ "Iteration: 40000, Error: 2379.093086548179\n",
+ "Iteration: 50000, Error: 612.9270618824643\n",
+ "Iteration: 60000, Error: 5197.901755236507\n",
+ "Iteration: 70000, Error: 3201.8070554313686\n",
+ "Iteration: 80000, Error: 265.6679530549633\n",
+ "Iteration: 90000, Error: 2466.7681125102044\n",
+ "Iteration: 100000, Error: 602.9843901795197\n",
+ "Iteration: 110000, Error: 50.16423143387052\n",
+ "Iteration: 120000, Error: 450.2998350146081\n",
+ "Iteration: 130000, Error: 4908.17917978217\n",
+ "Iteration: 140000, Error: 153.68311282520978\n",
+ "Iteration: 150000, Error: 3180.767818636309\n",
+ "Iterations: 151234, Error: 0.006872960595740857\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "[1.970702724699727, 3.0275199352116857]"
+ ]
+ },
+ "execution_count": 66,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "def random_next_solution(x_min, x_max, y_min, y_max):\n",
+ " return [random.uniform(x_min, x_max), random.uniform(y_min, y_max)]\n",
+ "\n",
+ "def do_random_search(x_min, x_max, y_min, y_max, max_iter=100*10000+1, quit_at_err=0.01):\n",
+ " for i in range(max_iter):\n",
+ " # Note that with this solution, we are artificially limiting the search window\n",
+ " current_solution = random_next_solution(x_min, x_max, y_min, y_max)\n",
+ " current_solution_err = error_function(current_solution)\n",
+ " if current_solution_err < quit_at_err:\n",
+ " print('Iterations: {}, Error: {}'.format(i, current_solution_err))\n",
+ " break\n",
+ " if i % 10000 == 0:\n",
+ " print('Iteration: {}, Error: {}'.format(i, current_solution_err))\n",
+ "\n",
+ " return current_solution\n",
+ "\n",
+ "do_random_search(-20, 20, -20, 20)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "So looks like the random uniform search is descent (though nowhere near the efficiency as the Genetic Algorithm). BUT, we had to limit the search window for x and y to (-20, 20). The Genetic Algorithm is is really nice because no such limitation of the window is necessary. With some problems, we don't have such a good idea of where the solution (or a good-enough solution) lies.\n",
+ "\n",
+ "Now, look how poorly the random search algorithm behaves when we expand the window to (-100, 100):"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 67,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Iteration: 0, Error: 87498.269900416\n",
+ "Iteration: 10000, Error: 19729.641085476345\n",
+ "Iteration: 20000, Error: 12088.16015937448\n",
+ "Iteration: 30000, Error: 70371.69304549509\n",
+ "Iteration: 40000, Error: 101228.17845615717\n",
+ "Iteration: 50000, Error: 3752.077746472049\n",
+ "Iteration: 60000, Error: 5678.870652708074\n",
+ "Iteration: 70000, Error: 13796.72050359031\n",
+ "Iteration: 80000, Error: 75143.37747065257\n",
+ "Iteration: 90000, Error: 45542.307427910455\n",
+ "Iteration: 100000, Error: 68761.573982296\n",
+ "Iteration: 110000, Error: 103085.07660772622\n",
+ "Iteration: 120000, Error: 3974.410160526244\n",
+ "Iteration: 130000, Error: 45856.8843360887\n",
+ "Iteration: 140000, Error: 82085.17905786278\n",
+ "Iteration: 150000, Error: 55998.276219948355\n",
+ "Iteration: 160000, Error: 13533.890847679402\n",
+ "Iteration: 170000, Error: 7714.684011843349\n",
+ "Iteration: 180000, Error: 86523.04016051191\n",
+ "Iteration: 190000, Error: 16543.62379364362\n",
+ "Iteration: 200000, Error: 16387.267717172082\n",
+ "Iteration: 210000, Error: 35095.89645941437\n",
+ "Iteration: 220000, Error: 21500.344783772187\n",
+ "Iteration: 230000, Error: 8602.127950229136\n",
+ "Iteration: 240000, Error: 23146.291821665374\n",
+ "Iteration: 250000, Error: 5573.538548409406\n",
+ "Iteration: 260000, Error: 15582.669051756802\n",
+ "Iteration: 270000, Error: 67460.89705168757\n",
+ "Iteration: 280000, Error: 22099.987714948118\n",
+ "Iteration: 290000, Error: 103875.00610584665\n",
+ "Iteration: 300000, Error: 34720.36015567349\n",
+ "Iteration: 310000, Error: 83594.23197451505\n",
+ "Iteration: 320000, Error: 12914.149660419593\n",
+ "Iteration: 330000, Error: 70952.46047816904\n",
+ "Iteration: 340000, Error: 59887.68169660277\n",
+ "Iteration: 350000, Error: 7520.050193027867\n",
+ "Iteration: 360000, Error: 44995.68257573622\n",
+ "Iteration: 370000, Error: 81291.94643393895\n",
+ "Iteration: 380000, Error: 41804.68036266295\n",
+ "Iteration: 390000, Error: 75533.79144602736\n",
+ "Iteration: 400000, Error: 40166.66863847164\n",
+ "Iteration: 410000, Error: 22777.252619958163\n",
+ "Iteration: 420000, Error: 33197.82810250713\n",
+ "Iteration: 430000, Error: 38228.650679926766\n",
+ "Iteration: 440000, Error: 23799.483498835998\n",
+ "Iteration: 450000, Error: 23362.13164486192\n",
+ "Iteration: 460000, Error: 55637.66175237792\n",
+ "Iteration: 470000, Error: 17834.702894950995\n",
+ "Iteration: 480000, Error: 8658.514188047018\n",
+ "Iteration: 490000, Error: 84567.11845740197\n",
+ "Iteration: 500000, Error: 94682.81767493288\n",
+ "Iteration: 510000, Error: 57374.14215140941\n",
+ "Iteration: 520000, Error: 133270.27557128755\n",
+ "Iteration: 530000, Error: 72186.95827586284\n",
+ "Iteration: 540000, Error: 3433.15872892808\n",
+ "Iteration: 550000, Error: 33586.914250072565\n",
+ "Iteration: 560000, Error: 68323.41411031733\n",
+ "Iteration: 570000, Error: 104327.49512416092\n",
+ "Iteration: 580000, Error: 58581.06509649316\n",
+ "Iteration: 590000, Error: 2425.8950816699307\n",
+ "Iteration: 600000, Error: 74158.4290486698\n",
+ "Iteration: 610000, Error: 59596.564761273505\n",
+ "Iteration: 620000, Error: 6032.790556750053\n",
+ "Iteration: 630000, Error: 19382.28625675643\n",
+ "Iteration: 640000, Error: 52113.27572042264\n",
+ "Iteration: 650000, Error: 16964.387182687533\n",
+ "Iteration: 660000, Error: 2566.9237548328633\n",
+ "Iteration: 670000, Error: 30745.90780684977\n",
+ "Iteration: 680000, Error: 9741.907422463612\n",
+ "Iteration: 690000, Error: 42375.54859504519\n",
+ "Iteration: 700000, Error: 35724.80283533997\n",
+ "Iteration: 710000, Error: 25734.247960276138\n",
+ "Iteration: 720000, Error: 8121.674922935857\n",
+ "Iteration: 730000, Error: 30344.43805352114\n",
+ "Iteration: 740000, Error: 48914.67262714829\n",
+ "Iteration: 750000, Error: 85613.73404147822\n",
+ "Iteration: 760000, Error: 17859.395898185354\n",
+ "Iteration: 770000, Error: 26279.316160791226\n",
+ "Iteration: 780000, Error: 2003.1869252535955\n",
+ "Iteration: 790000, Error: 70538.19320335564\n",
+ "Iteration: 800000, Error: 49188.62840047125\n",
+ "Iteration: 810000, Error: 20034.307571268408\n",
+ "Iteration: 820000, Error: 51024.020521718514\n",
+ "Iteration: 830000, Error: 33119.55340480031\n",
+ "Iteration: 840000, Error: 6755.657801786951\n",
+ "Iteration: 850000, Error: 22262.317303391013\n",
+ "Iteration: 860000, Error: 16174.411806687322\n",
+ "Iteration: 870000, Error: 26900.650286404183\n",
+ "Iteration: 880000, Error: 63639.462020066705\n",
+ "Iteration: 890000, Error: 1751.4986031186374\n",
+ "Iteration: 900000, Error: 130544.81195988822\n",
+ "Iteration: 910000, Error: 35406.58966007849\n",
+ "Iteration: 920000, Error: 9096.962857492243\n",
+ "Iteration: 930000, Error: 186.02024407888737\n",
+ "Iteration: 940000, Error: 16507.791284834748\n",
+ "Iteration: 950000, Error: 15890.978217479318\n",
+ "Iteration: 960000, Error: 21070.9556745879\n",
+ "Iteration: 970000, Error: 84199.18894773135\n",
+ "Iteration: 980000, Error: 11548.769004157894\n",
+ "Iteration: 990000, Error: 34477.79829390748\n",
+ "Iteration: 1000000, Error: 89978.66995960606\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "[-85.14712014026289, -30.728240396272312]"
+ ]
+ },
+ "execution_count": 67,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "do_random_search(-100, 100, -100, 100)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "So when we expand the search space, the results are much worse for the uniform random search."
+ ]
+ }
+ ],
+ "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.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}