Skip to content

Commit ee41fc3

Browse files
Merge pull request CamDavidsonPilon#125 from haraldschilly/master
CH3: 4 minor changes
2 parents f251ee3 + 0ac9ca9 commit ee41fc3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Chapter3_MCMC/IntroMCMC.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
"from mpl_toolkits.mplot3d import Axes3D\n",
4848
"\n",
4949
"fig = plt.figure()\n",
50-
"x = y = np.linspace(0,5, 100 )\n",
50+
"x = y = np.linspace(0, 5, 100 )\n",
5151
"X, Y = np.meshgrid(x, y)\n",
5252
"\n",
5353
"subplot(121)\n",
54-
"uni_x = stats.uniform.pdf( x,loc=0, scale = 5)\n",
55-
"uni_y = stats.uniform.pdf(x, loc=0, scale = 5)\n",
54+
"uni_x = stats.uniform.pdf(x, loc=0, scale = 5)\n",
55+
"uni_y = stats.uniform.pdf(y, loc=0, scale = 5)\n",
5656
"M = np.dot( uni_x[:,None], uni_y[None,:] )\n",
5757
"im = plt.imshow(M, interpolation='none', origin='lower',\n",
5858
" cmap=cm.jet, vmax=1, vmin = -.15, extent=(0,5,0,5))\n",
@@ -557,7 +557,7 @@
557557
"subplot(313)\n",
558558
"p_trace = mcmc.trace(\"p\")[:]\n",
559559
"plot( p_trace, label = \"$p$: frequency of assignment to cluster 0\",\n",
560-
" color = \"#467821\", lw = 1)\n",
560+
" color = \"#467821\", lw = lw)\n",
561561
"plt.xlabel( \"Steps\" )\n",
562562
"plt.ylim(0,1)\n",
563563
"plt.legend();"
@@ -809,7 +809,7 @@
809809
"\n",
810810
"During MCMC, we are returned vectors representing samples from the unknown posteriors. Elements of different vectors cannot be used together, as this would break the above logic: perhaps a sample has returned that cluster 1 has a small standard deviation, hence all the other variables in that sample would incorporate that and be adjusted accordingly. It is easy to avoid this problem though, just make sure you are indexing traces correctly. \n",
811811
"\n",
812-
"Another small example to illustrate the point. Suppose two variables, $x$ and $y$, are related by $x+y=10$. We model $x$ as a Normal random variable with mean 4 and explore 300 samples. "
812+
"Another small example to illustrate the point. Suppose two variables, $x$ and $y$, are related by $x+y=10$. We model $x$ as a Normal random variable with mean 4 and explore 500 samples. "
813813
]
814814
},
815815
{
@@ -878,7 +878,7 @@
878878
"In our case, $A$ represents $L_x = 1$ and $X$ is the evidence we have: we observe that $x = 175$. For a particular sample set of parameters for our posterior distribution, $( \\mu_0, \\sigma_0, \\mu_1, \\sigma_1, p)$, we are interested in asking \"Is the probability that $x$ is in cluster 1 *greater* than the probability it is in cluster 0?\", where the probability is dependent on the chosen parameters.\n",
879879
"\n",
880880
"\\begin{align}\n",
881-
"& P(L_x = 1| x = 175 ) \\gt P( (L_x = 0| x = 175 ) \\\\\\\\[5pt]\n",
881+
"& P(L_x = 1| x = 175 ) \\gt P(L_x = 0| x = 175 ) \\\\\\\\[5pt]\n",
882882
"& \\frac{ P( x=175 | L_x = 1 )P( L_x = 1 ) }{P(x = 175) } \\gt \\frac{ P( x=175 | L_x = 0 )P( L_x = 0 )}{P(x = 175) }\n",
883883
"\\end{align}\n",
884884
"\n",

0 commit comments

Comments
 (0)