Created
March 30, 2016 16:10
-
-
Save kylemcdonald/fba529f03bb699a379602812b4ec8d03 to your computer and use it in GitHub Desktop.
Fast generation of random numbers given a probability distribution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This is an example of building a lookup table for sampling from a probability distribution. First we set up Python from drawing graphics and using numpy." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib inline\n", | |
"from matplotlib import pyplot as plt\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Then we create a probability density function, which has a domain from 0 to 1 and sums to 1." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def curve(x):\n", | |
" return 1-np.cos((x*(2*np.pi)**2)**.5)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now we sample a bunch of points from the curve and draw it." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xu8VXP+x/HXp+tM6aJcK0WmJCKkC9GJKPdxGVKRe8jw\nYGaaGlHDuOUeEUJyy69cCiHJoUZIFyUlYYoaJZUoUqfv74/vSc3pnM7unL3Xd+2138/HYz+c01nt\n/W6pz177s74Xc84hIiLJVCF0ABERyRwVeRGRBFORFxFJMBV5EZEEU5EXE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VAKWeCzNrCDwPnOOc+yJA\nxqiUei6cc40LH3vh+/KXJ7DAQ2r/RsYA7c2soplVw99omxtxziikci7mAp0ACnvQTYEvI00ZHaPk\nT7BlqpvJww8bAAAAl0lEQVRpv5J3mjz1m1TOBXAdUAd4oPAKdr1zrugCcFkvxXPxP78l8pARSfHf\nyDwzewOYBRQADzvnPg0YOyNS/HtxC/C4mX2ML4B9nHMrwqXODDN7BsgD6prZIvyooiqUs25qMpSI\nSIJFvv2fiIhER0VeRCTBVORFRBJMRV5EJMFU5EVEEkxFXkQkwVTkRUQSTEVeRCTB/h9au7Bp0Kss\nSgAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10d12cf90>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"n_samples = 1024\n", | |
"x = np.linspace(0, 1, n_samples)\n", | |
"y = curve(x)\n", | |
"plt.plot(x, y)\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"One technique for sampling from the curve requires building a cumulative sum after normalizing the data:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG0VJREFUeJzt3XmUlNWd//H3F1zwZwwGcFxQiAvoDAgao+KR0UYNIDqi\nSOICMaNZmElQ4sQzxDCaHqOjjESjRESUo4MDAuIGioJoN7LKJijSDbiMYTVgAoRNsPv7++O20LbQ\nXXRX1a166vM6pw5d1Q/VXx+7P9z+Pve519wdERFJpkaxCxARkcxRyIuIJJhCXkQkwRTyIiIJppAX\nEUkwhbyISILVGfJmNtLMPjWzd2s55mEzW2lmi83sjPSWKCIi9ZXKSP5JoN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MGvVZVcq5+JxoJ2ZrQWWAAOyVFuuqVdu5t1Sw0llZl0Is5I6x64loj8A1XuySQ76uhwE\nfAe4CDgcmGNmc9z9g7hlRXE7sMTdu5jZycDrZtbB3bfGLiwfZCLk1wCtqj0/vuq1msecUMcxSZDK\nucDMOgAjgO7uXtuva/kslXPxXWCsmRmh93qpme1294lZqjFbUjkXq4GN7r4T2GlmbwEdCf3rJEnl\nXJwP3APg7h+a2cfAacCCrFSYO+qVm5lo1+y5ecrMDiHcPFXzh3QicAPsuaN2nzdPJUCd58LMWgHP\nAT909w8j1JgtdZ4Ldz+p6nEioS//8wQGPKT2M/IS0NnMGpvZ/yNcaCvLcp3ZkMq5KAMuAajqQbcF\nPspqldlj7P832HrlZtpH8q6bp/ZI5VwAdwDNgGFVI9jd7l5zAbi8l+K5+MpfyXqRWZLiz0i5mU0B\n3gUqgBHuvixi2RmR4vfFvcCTZraEEID/7u5/iVd1ZpjZGKAIaG5mfyLMKjqEBuamboYSEUmwvNn+\nT0REDpxCXkQkwRTyIiIJppAXEUkwhbyISIIp5EVEEkwhLyKSYAp5EZEE+/+QBwtcQATPuAAAAABJ\nRU5ErkJggg==\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10d1a9ad0>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"y /= n_samples\n", | |
"cumulative = np.cumsum(y)\n", | |
"plt.plot(x, cumulative)\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Then we can loop through the cumulative sum looking for which index corresponds to our sample." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAEACAYAAACuzv3DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJRE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3YCmCLMcbKZP0mNLDn0s8B\nAHQD8IkxptQYcxTA2wBOR+7dByD+z+zoXiQrkH8BoI2INBeRygCGApiRpGtlipcArDHGPBmwbwaA\n4b7tqwFMD9g/1PckvyWANtAJVZ5ljBlljGlmjGkF/feeb4y5EsC7yJ17UAJgi4j41nRHHwCrkUM/\nBz7rAJwmIlVFRKD3YQ1y4z4Igv8ijesz+7pfdolID9+9uyrgnMiS+AT3Aug/6LcARqT7iXIyv6Ct\n0aPQ0TnLACz1ff76AOb57sNcAHUDzhkJfVK9FsD56f4MLt+Ps+EftZJT9wBAJ2hDZjmAt6CjVnLq\nHvg+173QX2JfQR/yVcr2+wDgFQDbAByEPh+4BkC9eD8zgFMArPTFziftXJsTgoiIPI4PO4mIPI6B\nnIjI4xjIiYg8joGciMjjGMiJiDyOgZyIyOMYyImIPI6BnIjI4/4fnszwY+Q5MEMAAAAASUVORK5C\nYII=\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10d3d4a90>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"random_weights = np.random.random(10000)\n", | |
"indices = []\n", | |
"for random_weight in random_weights:\n", | |
" index = 0\n", | |
" while index < n_samples and random_weight > cumulative[index]:\n", | |
" index += 1\n", | |
" start = index\n", | |
" end = index + 1\n", | |
" rand = np.random.uniform(start, end)\n", | |
" indices.append(index)\n", | |
"plt.hist(indices, bins=n_samples/2, histtype='step')\n", | |
"plt.xlim([0,n_samples])\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"If we need to take a lot of samples, the loop can be slow. So instead we can precompute the inverse of the cumulative sum:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEACAYAAAC+gnFaAAAABHNCSVQICAg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Rnu/nnc\ngeWDuBLBFuCECp9bR9sq79Omin3qgupcC8zsDGAk0MvdD1cszGfVuRY/AMabmRHqgnubWYm7T8lS\njNlSnWuxGfjY3fcCe81sPnAmoT69LqnOtTgfeBDA3f9uZu8DpwLLsxJhbqnxvTOuqqFlQHsza2tm\nDYBrgMp/yFOAG+CrEcmfuHtxdsPMiiqvhZmdAEwCBrn732OIMVuqvBbuflL0OpHQTnBHHUwCUL2/\nkcnABWZ2pJl9i9AwWBfH5VTnWqwBLgWI6sNPAd7LapTZZRy6NFzje2csJQI/xMAyM/tp+LGPdPdp\nZtbHzN4FdhOqROqc6lwL4H6gKfBE9CRc4u5nxxd17ajmtfjaIVkPMkuq+TfyjpnNBFYC+4GR7r46\nxrBrRTV/Lx4CRpvZCsIN8h53/0d8UdceMxsHJIBmZvYBocdUA9K4d2pAmYhIgdPsoyIiBU6JQESk\nwCkRiIgUOCUCEZECp0QgIlLglAhERAqcEoGISIFTIhARKXD/H7vLTRhuIkzXAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10d47c210>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"inv_cumulative = []\n", | |
"for weight in np.linspace(0, 1, n_samples):\n", | |
" index = 0\n", | |
" while index < n_samples and weight > cumulative[index]:\n", | |
" index += 1\n", | |
" inv_cumulative.append(index)\n", | |
"plt.plot(x, inv_cumulative)\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Even better is to compute this from scratch, since re-using the cumulative sum can create sampling artifacts:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+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Xu4G6ZQxPBfa7e00BaywId18FHDhBkxblZj5CPqc3T5W4TM5FQ3cCi/NaUXTSngsz\nOxsY5e6PAHGeiZXJz8VFwOlmtsLM1prZrQWrrrAyORdTgEvM7B1gA/D9AtVWbFqUm0Wz/V9rZ2aD\nCLOSBkRdS4QeABqOycY56NNpB1wGfBn4FLDGzNa4+7Zoy4rEPcAGdx9kZucDy82st7u/H3VhpSAf\nIb8L6Nbg+Tmp7zVuc26aNnGQybnAzHoDk4Eydz/Rf9dKWSbn4gpgppkZYex1iJlVu/v8AtVYKJmc\ni53APnf/EPjQzJ4HLiWMX8dJJufiGuA+AHd/w8zeBHoC6wpSYfFoUW7mY7jm+M1TZtaBcPNU41/S\n+cBtcPyO2iZvnoqBtOfCzLoBc4Fb3f2NCGoslLTnwt0/l3r0IIzLfzeGAQ+Z/Y7MAwaYWVsz+xPC\nhbbKAtdZCJmci0rgeoDUGPRFwPaCVlk4RvP/g21Rbua8J++6eeq4TM4FcC9wOvBwqgdb7e59o6s6\nPzI8F3/wloIXWSAZ/o5sMrOlwEagFpjs7r+PsOy8yPDn4ifANDPbQAjAf3L3/4uu6vwwsxlAAuhs\nZm8TZhV1IMvc1M1QIiIxFtlG3iIikn8KeRGRGFPIi4jEmEJeRCTGFPIiIjGmkBcRiTGFvIhIjCnk\nRURi7P8BzM1S/ClAnrIAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10d513bd0>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"total = 0\n", | |
"position = 0\n", | |
"step_size = 1./(n_samples*10)\n", | |
"inv_cumulative = []\n", | |
"for target in np.linspace(0, 1, n_samples):\n", | |
" while target > total:\n", | |
" position += step_size\n", | |
" total += curve(position) * step_size\n", | |
" inv_cumulative.append(position)\n", | |
"plt.plot(x, inv_cumulative)\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Or better again, we can compute it directly by taking the integral of our original function and solving for `x`, but if the probability distribution is not already represented symbolically this won't be possible.\n", | |
"\n", | |
"Once we have the evenly-spaced inverse cumulative lookup table we can sample it directly without a loop." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEACAYAAABMEua6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XeYFFXWBvD3DElyTkoQlaDwqaAiGNgxI5LMaRU+dDHr\nfkZY1wVcFOOuEVcUlVUxEWQIShAGMICgiAFBiZJmGEBhQGDS/f44U3buru6uTtXv73n66eoKt+70\n9JypvnXvuWKMARERuUNOqitARETOYVAnInIRBnUiIhdhUCcichEGdSIiF2FQJyJyEVtBXUTqi8gH\nIvKjiPwgIqeKSEMRmSMia0RktojUT3RliYgoPLtX6s8CmGWMORbACQBWAxgGYJ4xpiOA+QCGJ6aK\nRERkl0QafCQi9QCsMMYc7bd+NYA/GWMKRaQFgHxjTKfEVZWIiCKxc6XeDsBOEXldRL4WkXEiUgtA\nc2NMIQAYYwoANEtkRYmIKDI7Qb0qgG4AXjTGdAOwH9r04n+Jz3wDREQpVtXGPlsAbDbGLK98PRka\n1AtFpLlX88uOYAeLCIM9EVEMjDES7TERr9Qrm1g2i0iHylXnAPgBQB6AwZXrBgGYFqYMPozBiBEj\nUl6HdHnwveB7wfci/CNWdq7UAeBOAG+LSDUA6wH8L4AqAN4XkSEANgG4IuZaEBGRI2wFdWPMSgCn\nBNl0rrPVISKieHBEaRLl5uamugppg++FB98LD74X8YvYTz3uE4iYRJ+DiMhtRAQmETdKiYgoczCo\nExG5CIM6EZGLMKgTEbkIgzoRkYswqBMRuQiDOhGRizCoExG5CIM6EZGLMKgTEbkIgzoRkYswqBMR\nuQiDOhGRizCoExG5CIM6EZGLMKg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dANwNoDaAL4QkS+MMWtTW62UGA5gpTHmLBE5GsBcETneGLMv1RXLBE4F9a0A2ni9blW5zn+f\n1hH2cQM77wVE5HgA4wD0NsaE+/qVqey8DycDeFdEBNp2eqGIlBpj8pJUx2Sx815sAbDTGHMQwEER\nWQTgBGj7s5vYeS9OB/AIABhj1onIBgCdACxPSg3TS9Rx06nml2UAjhGRtiJSHcBVAPz/MPMAXA/8\nMRr1N2NMoUPnTycR3wsRaQNgMoDrjDHrUlDHZIj4Phhjjqp8tIO2q9/qwoAO2Pv7mAbgDBGpIiK1\noDfF3Djuw8578SOAcwGgsv24A4D1Sa1lcglCf0uNOm46cqVuQgxEEpGbdLMZZ4yZJSJ9RGQtgP3Q\nZgfXsfNeAHgIQCMAYyuvUkuNMXHOkZ5ebL4PPockvZJJYvPvY7WIzAbwLYByAOOMMatSWO2EsPm5\nGAPgdRFZCQ129xtjdqeu1okjIhMB5AJoLCK/QHv+VEcccZODj4iIXITT2RERuQiDOhGRizCoExG5\nCIM6EZGLMKgTEbkIgzoRkYswqBMRuQiDOhGRi/w/hZHcNIIOYlMAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10d62e390>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"lookups = np.random.randint(0, n_samples, 10000)\n", | |
"sampled = []\n", | |
"for lookup in lookups:\n", | |
" start = inv_cumulative[lookup]\n", | |
" end = inv_cumulative[lookup+1] if lookup+1 < n_samples else 1\n", | |
" rand = np.random.uniform(start, end)\n", | |
" sampled.append(rand)\n", | |
"plt.hist(sampled, bins=n_samples/2, histtype='step')\n", | |
"plt.xlim([0,1])\n", | |
"plt.show()" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment