Last active
January 25, 2019 00:19
-
-
Save bellecp/c8f32170103d5cb8143c6d981a454c36 to your computer and use it in GitHub Desktop.
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
name: example-environment | |
dependencies: | |
- numpy | |
- scipy | |
- matplotlib |
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": "code", | |
"execution_count": 41, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"from scipy.stats import expon\n", | |
"from scipy import stats\n", | |
"import random\n", | |
"def proposal(x):\n", | |
" return x + random.randint(-5,5)\n", | |
"\n", | |
"n = 100\n", | |
"\n", | |
"density = lambda k: stats.binom.pmf(k, n, 0.75)\n", | |
"\n", | |
"def accept(x, y):\n", | |
" acceptance_proba = min(1, density(y)/density(x))\n", | |
" if np.random.uniform(0,1) < acceptance_proba:\n", | |
" return True\n", | |
" else:\n", | |
" return False\n", | |
"\n", | |
"def next_state(x):\n", | |
" y = proposal(x)\n", | |
" if accept(x, y):\n", | |
" return y\n", | |
" else:\n", | |
" return x\n", | |
"\n", | |
"def run_chain(n, x0):\n", | |
" states = []\n", | |
" current = x0\n", | |
" for i in range(n):\n", | |
" current = next_state(current)\n", | |
" states.append(current)\n", | |
" return states\n", | |
"\n", | |
"output = run_chain(1000, 1.0)\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cG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O+X97GXaF0d1bW++E1gSarUoC4BSZJmYQBIUqUMAEmqlAEgSZUyACSpUgaAJFXKAJCkShkAklSp/wdHWUD6IgAW+AAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"import matplotlib.pyplot as plt\n", | |
"plt.bar(range(n+1), np.bincount(output, minlength=n+1))\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[<matplotlib.lines.Line2D at 0x7f681dc5e1d0>]" | |
] | |
}, | |
"execution_count": 43, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XtwXGeZ5/Hv0627ZN1lS7LsyMYm2AkhCY4TWJhlCRkShsFQhNkEakhtZSZzIQOzzO5sWGrZgZqaqmxNTZipZNlKEdiQYXIhy84aCMkMCcxACpzYCSTxjSi+ypIvsm7WXep+9o8+bcsdyWpJ3X1a3b9PVcrdp9/ufk4d59ev3/Oe85q7IyIixSESdgEiIpI7Cn0RkSKi0BcRKSIKfRGRIqLQFxEpIgp9EZEiotAXESkiCn0RkSKi0BcRKSIlYReQqrm52Ts7O8MuQ0RkRdmzZ0+fu7cs1C7vQr+zs5Pdu3eHXYaIyIpiZkfTaafhHRGRIqLQFxEpIgp9EZEiotAXESkiCn0RkSKi0BcRKSIKfRGRIqLQF5GseHb/KQ6cHA67DEmh0BeRjOsZHOf3v7Wb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es>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"# Here we plot the exact pmf of the binomial(100,0.75) distribution\n", | |
"plt.plot(range(n+1), [density(k) for k in range(n+1)]) " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"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.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment