Skip to content

Instantly share code, notes, and snippets.

@JonathanReeve
Last active October 20, 2016 20:36
Show Gist options
  • Save JonathanReeve/136da2000db87f38ee97e052f9b13ef6 to your computer and use it in GitHub Desktop.
Save JonathanReeve/136da2000db87f38ee97e052f9b13ef6 to your computer and use it in GitHub Desktop.
gibbs sampler
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Gibbs Sampler for misture of Gaussians"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We implement a Gibbs sampler for detecting the centers of a specified number of clusters based on a Gaussian mixture model. Work done by Rachel Levanger for Fall 2016 Foundation of Graphical Models at Columbia University, HW #2."
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Generate the sample dataset"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We specify K clusters and randomly select their means from a Gaussian distribution centered at zero with high variance (to spread them out). We then randomly choose a membership according to a uniform distribution for each datapoint, then generate that datpoint's position according to a multivariate normal distribution centered at the selected mean with some pre-specified variance common to all clusters"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Generate the means of the Gaussian mixture"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Set the number of clusters\n",
"K = 3\n",
"\n",
"# Set the variance of the distribution of means\n",
"p_lambda = 1000\n",
"\n",
"# Randomly choose K means according to N((0,0),p_lambda) distribution\n",
"mu_x, mu_y = np.random.multivariate_normal([0,0], p_lambda*np.identity(2) , 3).T\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Generate the sample data according to the generated means of the Gaussian mixture"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Set the number of datapoints in the sample\n",
"N = 100\n",
"\n",
"# Set the variance of each of the clusters\n",
"sigma = 50.\n",
"\n",
"# Initialize the dataset\n",
"x=np.zeros(N)\n",
"y=np.zeros(N)\n",
"\n",
"# Loop through each datapoint and assign it to a cluster, then generate its position\n",
"for n in range(0,N):\n",
" k = np.random.choice(K)\n",
" x[n], y[n] = np.random.multivariate_normal([mu_x[k],mu_y[k]], sigma*np.identity(2) , 1).T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plot the sample data and the means"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(-30.0, 70.0, -50.0, 40.0)"
]
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEACAYAAACj0I2EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+wXHWZ5/H3YyKJIzNe2a0JCJGkopTEuOCPAZaMscfh\nJkhY0NqSMEumUFMrtcGEcidcA0FzKZJaxIyjRLCchdmiRCCsuhTcK4Sr0qQ2rqODGIiBRah7A1HB\n2SVNSc0m/Hr2j+/p2337dvftH+d0n3Pu51XVdfucPuf0OTedp7/3+T7n+zV3R0REsu9N/T4BERGJ\nhwK6iEhOKKCLiOSEArqISE4ooIuI5IQCuohITsQS0M1sjpk9amb3RcvHmdmYmT1lZg+a2UAc7yMi\nIo3F1UK/AjgAlIvaNwNj7n4K8KNoWUREEtR1QDezk4DzgFsAi1ZfANwWPb8N+Hi37yMiIs3F0UL/\nO+BK4I2qdQvc/YXo+QvAghjeR0REmugqoJvZ+cDv3f1RKq3zKTyMLaDxBUREEja3y/3PBi4ws/OA\n+cCfmNm3gRfM7Hh3f97MTgB+X7ujmSnIi4h0wN3rNqC7aqG7+9XuvtDdFwMXAz92978G7gUujTa7\nFLinwf6xPLZu3Rrbsfr5y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v7/wUws+8D/5YeXEcmUy7uvt/dF7j7YndfTPggfCD6c+Ze4GIzO8bMFtPgxqa0\nMLNzCX8mX+juR6peytR1AP8EvNvMFpnZMYQO3Xv7fE4zstAiuBU44O5fq3rpXuDS6PmlwD21+6aJ\nu1/t7guj/w8XAz92978mQ9fh7s8Dz5nZKdGqc4BfAfeRkWuIHATOMrO3RJ+vcwgd1YlfR6pb6G2Y\n/NMlgzc27QSOAcaivzb+l7uvz9p1uPtrZvY5YDehV/9Wd3+iz6fViuXAWuAxM3s0WncVcD1wt5mt\nAyaAi/pzeh0rf1aydh0bgO9EjYJngE8TPk+ZuQZ3/5mZfRf4BeH/7i+Avwf+mISvQzcWiYjkRCZT\nLiIiMp0CuohITiigi4jkhAK6iEhOKKCLiOSEArqISE4ooIuI5IQCuohITvx/Ete3744APtoAAAAA\nSUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x106567150>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Plot the means\n",
"plt.plot(x, y, 'x', markerfacecolor='blue')\n",
"plt.plot(mu_x, mu_y, 'x', marker='o', markerfacecolor='red')\n",
"plt.axis('equal')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Implement the Gibbs sampler"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Forthcoming..."
]
}
],
"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