Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Distribution of a Gaussian Random Walk
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"walks = do_walk(1000,5000)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"dist = np.zeros(1000)\n",
"for i in range(1000):\n",
" dist[i] = walks[i][4999]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlkAAAEyCAYAAADJI8VDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAERVJREFUeJzt3W+sZGddB/Dvzy7yAjCldlubtnqLqYbyQigbUoMaDIY/\nrVqIwcAL2SDJ+gISSDRxsS8gISRFAyaNCCmhoTUIkgDS2CrUBiUm8meLpbSWwgIrXbrpLmAAg6kW\nHl/MuTqs9+693Xt/nXvnfj7JZM4855mZ33nm3LPfPWfOnBpjBACA7fVjiy4AAGAZCVkAAA2ELACA\nBkIWAEADIQsAoIGQBQDQQMgCAGggZAEANBCyAAAa7Ft0AUly/vnnj5WVlUWXAQCwobvuuuubY4z9\nG/XbESFrZWUlR44cWXQZAAAbqqp/20w/hwsBABoIWQAADYQsAIAGQhYAQAMhCwCggZAFANBAyAIA\naCBkAQA0ELIAABoIWQAADYQsAIAGO+LahQAdVg7ftugSts2x669ZdAnAY2RPFgBAAyELAKCBkAUA\n0EDIAgBoIGQBADQQsgAAGghZAAANhCwAgAZCFgBAAyELAKCBkAUA0EDIAgBoIGQBADTYt+gCgJ1l\n5fBtiy4BYCnYkwUA0EDIAgBoIGQBADQQsgAAGghZAAANhCwAgAYbhqyqurSqPlFV91fVfVX1uqn9\nvKq6o6q+PN0/dWqvqrqhqo5W1T1VdWX3QgAA7DSb2ZP1aJLfH2M8PclVSV5TVVckOZzkzjHG5Unu\nnB4nyYuTXD7dDiV557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cSGb/CCW5\nYGHVPX7WW+a9uG7sye1BVa0keVaST6dpfWj7nazHQ1X9fZKfWmPWdWOMj059rkvyaJL3rT5tjf4j\nawfOHf/7FpsZgzWcSPLTY4xvVdWzk/x1VT0jm7jm5E50lmOwVOvB6c40JknemeTNmS3Xm5O8LbP/\niOzKz/8s7aVlPd1zxxgPVdUFSe6oqi8uuqAdZq+tG3tye1BVT07yoSSvH2N89wxfP97SOOzqkDXG\n+LUzza+qg0l+Pcnzp8NfyZmvq3jG6y3uRBuNwTrPeSTJI9P0XVX1lSQ/l9nYXDLXdWnHIEu2Hpxu\ns2NSVe9O8jfTww2vObpE9tKy/ogxxkPT/cmq+khmh4AerqqLxhgnpkMhJxda5ONjvWXeU+vGGOPh\n1em9sj2oqidkFrDeN8b48NTcsj4s7eHCqnpRkj9M8ptjjO/Pzbo1ycur6olVdVmSyzP7sveeud5i\nVe2vqnOm6adlNgZfnXaRfq+qrqpZrH9lkvX2BO12e3Y9OO37BC9Nsnqm0XpjsoyW/nNeS1U9qaqe\nsjqd2QlC92a27AenbgezvH/389Zb5luTvHI6q+yqJN9ZPYy0jPba9mD6t+09Se4fY7x9blbP+rDo\nb/p33TL7kt6DSe6ebu+am3ddZmdKPJC5s+cyO4vgS9O86xa9DNswBi/NLIU/kuThJB+b2n8ryX2Z\nnTnyuSS/MfecA5n9kX0lyZ9luirAbr2tNwZ7aT1YY0z+IskXktwzbUAu2mhMlvG27J/zOsv8tOnv\n/vPTNuC6qf0nk9yZ5MvT/XmLrnWbl/v9mX1N4r+n7cGr11vmzA4PvWNaL76QubOSd/ttnXHYU9uD\nJL+U2eG+e+bywdVd64PL6gAANFjaw4UAAIskZAEANBCyAAAaCFkAAA2ELACABkIWAEADIQsAoMH/\nANVZ1HAbZ83PAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x7f1352865128>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(10,5))\n",
"ax = fig.add_subplot(1,1,1)\n",
"ax.hist(dist)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"So we see that the final points of our random walks are distributed according to something that pretty much looks like a Gaussian distribution."
]
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment