Skip to content

Instantly share code, notes, and snippets.

@ColCarroll
Created September 6, 2017 00:19
Show Gist options
  • Save ColCarroll/2cb6c7da86827b5ba7a3885d03ac48e7 to your computer and use it in GitHub Desktop.
Save ColCarroll/2cb6c7da86827b5ba7a3885d03ac48e7 to your computer and use it in GitHub Desktop.
Experiments in sampling from a pdf
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sample from a pdf\n",
"\n",
"The goal here is to take a pdf, and generate samples from that pdf. This is in support of a javascript library doing the same, so I've only used the standard library, instead of leaning too hard into `numpy`. The first part defines the functions used, and the last bit is a demo."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def area(x, y, x_prev, y_prev):\n",
" \"\"\"Area of the trapezoid with vertices ((x_prev, 0), (x_prev, y_prev), (x, y), (x, 0))\"\"\"\n",
" return (x - x_prev) * 0.5 * (y + y_prev)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def integrate(tuples):\n",
" \"\"\"Trapezoidal rule?\"\"\"\n",
" x_prev, y_prev = tuples[0]\n",
" tot = 0\n",
" for x, y in tuples[1:]:\n",
" tot += area(x, y, x_prev, y_prev)\n",
" x_prev, y_prev = x, y\n",
" return tot"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def get_cdf(tuples):\n",
" \"\"\"Actually turning the tuples into a list of dictionaries for future processing\"\"\"\n",
" tot = integrate(tuples)\n",
" data = sorted([(x, y/tot) for x, y in tuples])\n",
" x_prev, y_prev = data[0]\n",
" cdf = [{'x': x_prev, 'x_prev': x_prev, 'cdf': 0, 'a': 0, 'b': 0, 'c': 0}]\n",
" for x, y in data[1:]:\n",
" prev_cdf = cdf[-1]['cdf']\n",
" delta_cdf = area(x, y, x_prev, y_prev)\n",
" # computing interpolating quadratic on the fly, using the equation\n",
" # y(z) = a (z - x_prev)^2 + b(z - x_prev) + c; x_prev < z <= x\n",
" cdf.append({\n",
" 'x': x,\n",
" 'x_prev': x_prev,\n",
" 'cdf': prev_cdf + delta_cdf,\n",
" 'c': prev_cdf,\n",
" 'b': y_prev,\n",
" 'a': 0.5 * (y - y_prev) / (x - x_prev), \n",
" })\n",
" x_prev, y_prev = x, y\n",
" \n",
" return cdf"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# not used, but might as well compute\n",
"def get_cdf_fn(cdf):\n",
" def cdf_(x):\n",
" for data in cdf:\n",
" if data['x'] >= x:\n",
" m = x - data['x_prev']\n",
" return data['a'] * m * m + data['b'] * m + data['c']\n",
" return 1\n",
" return cdf_"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def get_inv_cdf_fn(cdf):\n",
" \"\"\"Get a function from a probability back into feature space\"\"\"\n",
" def inv_cdf(y):\n",
" \"\"\"This could probably be a binary search instead ¯\\_(ツ)_/¯\"\"\"\n",
" if y < 0:\n",
" return float('-inf')\n",
" for data in cdf:\n",
" if data['cdf'] > y:\n",
" # This gets a little hairy because the quadratic formula\n",
" # Has to shift back to be centered around 0, not x_prev\n",
" x_prev = data['x_prev']\n",
" a = data['a']\n",
" b = data['b'] - 2 * data['a'] * x_prev\n",
" c = a * x_prev * x_prev - data['b'] * x_prev + data['c']\n",
" return (-b + (b * b - 4 * a * (c - y)) ** 0.5) / (2 * a)\n",
" return float('inf')\n",
" return inv_cdf\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def sample_from_pdf(pdf, n):\n",
" \"\"\"Generate n samples from a list of (possibly unnormalized) x,y tuples. Assumes all y > 0.\"\"\"\n",
" inv_cdf = get_inv_cdf_fn(get_cdf(pdf))\n",
" for x in np.random.random(n):\n",
" yield inv_cdf(x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example usage\n",
"\n",
"We can generate a pdf, then sample from it, and demonstrate that the histogram of samples looks like the \n",
"plot of the pdf."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(0, 20, 1000)\n",
"y = np.maximum(np.sin(x), 0)\n",
"pdf = np.vstack((x, y)).T"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXmQZNdVp7+TW2VV1r713uqWumWpJcu2aAt7BMbYwpbM\njMSYTYohMOBA4cBiMGuYgFA4zB+DceCJYPDYGOwwEHiFARojj9AYgzFYtlqW3FJLlrvV6q26a8vM\nWjKzcr/zx3svK7u6sioz67182/0iKroy81W+2zdv/u65555zriil0Gg0Gk2wiLjdAI1Go9HYjxZ3\njUajCSBa3DUajSaAaHHXaDSaAKLFXaPRaAKIFneNRqMJIFrcNRqNJoBocddoNJoAosVdo9FoAkjM\nrRtPTk6qQ4cOuXV7jUaj8SVPP/30olJqarvrXBP3Q4cOcfLkSbdur9FoNL5ERC60c512y2g0Gk0A\n0eKu0Wg0AUSLu0aj0QQQLe4ajUYTQLS4azQaTQDZVtxF5FMiMi8iz7d4XUTkj0TkrIicEpE77W+m\nRqPRaDqhHcv908C9W7x+H3DU/HkY+NjOm6XRaDSanbCtuCulvgZktrjkAeAvlMGTwKiI7LGrgb2k\nXlf846mrfPLrrzC/WnS7OaFjMVfiU19/hS+dukKtro9/7DUnz2f4k399me/OrrjdFI0N2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\ndnTSEZGUiAxZv2NsyD2/4bITwM+KwRuA5ablotO0tKbc6K8NNI+jdwF/v8k1jwNvE5Ex0w3xNvM5\nRxCRe4HfAu5XShVaXNPOZ+5E25r3af5ri3u28/11gnuA7yqlLm/2opN9toU2uDO+7N4xtvMHI7rj\nexi77r9jPvdBjAEPkMRY5p8FvgXc2IM2/QDGsuoU8Kz58w7gPcB7zGseAU5jRAg8CfynHrTrRvN+\n3zHvbfVXc7sE+KjZn88Bx3v0OaYwxHqk6TlX+gtjgrkKVDD8mu/G2Kf5CnAG+H/AuHntceDPmv72\nF8yxdhb4eYfbdBbDB2uNMSsqbC/w2FafeQ/66y/N8XMKQ7j2bGyb+fi676+T7TKf/7Q1rpqu7Umf\nbaENrowvnaGq0Wg0AcTLbhmNRqPRdIkWd41GowkgWtw1Go0mgGhx12g0mgCixV2j0WgCiBZ3jUaj\nCSBa3DUajSaAaHHXaDSaAPL/Ada2BWAQ3CzzAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x10dab6390>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pdf[:, 0], pdf[:, 1]);"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"samples = list(sample_from_pdf(pdf, 100000))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE8FJREFUeJzt3X+spNV93/H3J/xwKhsZCFuKYZ3FzqYRjhSMVuDUbkRD\nw69EWVyl7qIo3jiom6ig2mqqZu1IseuUCtraVl25ROuw8jpyDTS2yypeB68JkuU/+LFQDCzY4RqD\n2NUCa0PAllW3i7/9Y87i8eX+mLt3Zu69e94vaTTPnOc8M2eemTufPec8z7OpKiRJ/fmplW6AJGll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P0v2OTmOWe5o3BESt/y+Bo\ngj9uZR9m8AcB8NMMhhNmgHuBN02hTe9g0H17CHiw3a4E/gD4g1bnOmA/gyMf7gb+0ZT215vaa369\nvf7RfTbctjD4j3u+BTwMbJpS217L4Af99UNlU99nDALoEPD/GIyxXsNg3uhO4HHgK8Dpre4m4M+H\ntv299l2bAd4zhXbNMBgTPvo9O3rE2xuAPQt95hNu11+0785DDH7Yzprdrvb4VX+/k2xXK//U0e/U\nUN1p7q/5fh+m/h3zTGBJ6tRaHwKSJB0jA0CSOmUASFKnDABJ6pQBIEmdMgAkqVMGgCR1ygCQpE79\nf/HgxUDx7uNBAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x10db485f8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.hist(samples, bins=100);"
]
}
],
"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.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment