From 3137f6aad7694d376013cbed0d4568f1139d7400 Mon Sep 17 00:00:00 2001 From: Harald Schilly Date: Thu, 22 Aug 2013 19:21:49 +0200 Subject: [PATCH 1/4] the example shows 500 samples, not 300 --- Chapter3_MCMC/IntroMCMC.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter3_MCMC/IntroMCMC.ipynb b/Chapter3_MCMC/IntroMCMC.ipynb index c370004e..6a848742 100644 --- a/Chapter3_MCMC/IntroMCMC.ipynb +++ b/Chapter3_MCMC/IntroMCMC.ipynb @@ -809,7 +809,7 @@ "\n", "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", "\n", - "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. " + "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. " ] }, { From 834022c1b02bf16c5fa34d51e66fc3db5bc9de03 Mon Sep 17 00:00:00 2001 From: Harald Schilly Date: Thu, 22 Aug 2013 19:26:39 +0200 Subject: [PATCH 2/4] lw variable is used everywhere except here --- Chapter3_MCMC/IntroMCMC.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter3_MCMC/IntroMCMC.ipynb b/Chapter3_MCMC/IntroMCMC.ipynb index 6a848742..0ba69f37 100644 --- a/Chapter3_MCMC/IntroMCMC.ipynb +++ b/Chapter3_MCMC/IntroMCMC.ipynb @@ -557,7 +557,7 @@ "subplot(313)\n", "p_trace = mcmc.trace(\"p\")[:]\n", "plot( p_trace, label = \"$p$: frequency of assignment to cluster 0\",\n", - " color = \"#467821\", lw = 1)\n", + " color = \"#467821\", lw = lw)\n", "plt.xlabel( \"Steps\" )\n", "plt.ylim(0,1)\n", "plt.legend();" From bd45dd4b73f67111bedf0a8541249f0067988a39 Mon Sep 17 00:00:00 2001 From: Harald Schilly Date: Thu, 22 Aug 2013 19:28:21 +0200 Subject: [PATCH 3/4] lowercase x and y are defined (same object), but only x is used. substituting to y makes more sense; minor whitespace edits --- Chapter3_MCMC/IntroMCMC.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Chapter3_MCMC/IntroMCMC.ipynb b/Chapter3_MCMC/IntroMCMC.ipynb index 0ba69f37..5e64bbfa 100644 --- a/Chapter3_MCMC/IntroMCMC.ipynb +++ b/Chapter3_MCMC/IntroMCMC.ipynb @@ -47,12 +47,12 @@ "from mpl_toolkits.mplot3d import Axes3D\n", "\n", "fig = plt.figure()\n", - "x = y = np.linspace(0,5, 100 )\n", + "x = y = np.linspace(0, 5, 100 )\n", "X, Y = np.meshgrid(x, y)\n", "\n", "subplot(121)\n", - "uni_x = stats.uniform.pdf( x,loc=0, scale = 5)\n", - "uni_y = stats.uniform.pdf(x, loc=0, scale = 5)\n", + "uni_x = stats.uniform.pdf(x, loc=0, scale = 5)\n", + "uni_y = stats.uniform.pdf(y, loc=0, scale = 5)\n", "M = np.dot( uni_x[:,None], uni_y[None,:] )\n", "im = plt.imshow(M, interpolation='none', origin='lower',\n", " cmap=cm.jet, vmax=1, vmin = -.15, extent=(0,5,0,5))\n", From 0ac9ca9c0d6aa928fec4a8c619c31a3ee02b6570 Mon Sep 17 00:00:00 2001 From: Harald Schilly Date: Thu, 22 Aug 2013 19:39:58 +0200 Subject: [PATCH 4/4] superfluous parenthesis --- Chapter3_MCMC/IntroMCMC.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter3_MCMC/IntroMCMC.ipynb b/Chapter3_MCMC/IntroMCMC.ipynb index 5e64bbfa..00a870e5 100644 --- a/Chapter3_MCMC/IntroMCMC.ipynb +++ b/Chapter3_MCMC/IntroMCMC.ipynb @@ -878,7 +878,7 @@ "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", "\n", "\\begin{align}\n", - "& P(L_x = 1| x = 175 ) \\gt P( (L_x = 0| x = 175 ) \\\\\\\\[5pt]\n", + "& P(L_x = 1| x = 175 ) \\gt P(L_x = 0| x = 175 ) \\\\\\\\[5pt]\n", "& \\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", "\\end{align}\n", "\n",