From 0c2c8ee8bc2a125d7eefcb3a33b2263ad4a3dc75 Mon Sep 17 00:00:00 2001 From: aaaakshat <33050725+aaaakshat@users.noreply.github.com> Date: Wed, 3 Nov 2021 16:52:07 -0400 Subject: [PATCH] Move grid behind lines --- ch08.r | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ch08.r b/ch08.r index ff4bc7c..7866ea7 100644 --- a/ch08.r +++ b/ch08.r @@ -43,9 +43,9 @@ L_df = data.frame(L) colnames(L_df) = S plot(theta, L_df$"12", type="n") +grid() lines(theta, L_df$"12", lwd=6) title(expression(paste("L(", theta, " | S = 12)"))) -grid() ## ML estimation for single-photon imaging @@ -83,20 +83,20 @@ theta = seq(0.1, 0.9, (0.1+0.9)/1000) L = S * log(theta) + (N-S) * log(1-theta) plot(theta, L, type="n", xlab=expression(theta), ylab=expression(paste("Log L(", theta, "|S = 20)"))) title("Bernoulli") -lines(theta, L, lwd=6, col="#8080BF") grid() +lines(theta, L, lwd=6, col="#8080BF") h_theta = -log(1-theta) plot(theta, h_theta, type="n", xlab=expression(theta), ylab=expression(paste(eta, " = h(", theta, ")"))) -lines(theta, h_theta, lwd=6) grid() +lines(theta, h_theta, lwd=6) theta = seq(0.1, 2.5, (0.1+2.5)/1000) L = S * log(1-exp(-theta)) - theta * (N-S) plot(theta, L, type="n") title("Truncated Poisson") -lines(theta, L, lwd=6, col="#0000BF") grid() +lines(theta, L, lwd=6, col="#0000BF") ############# # Chapter 8.3 Maximum-a-Posteriori Estimation @@ -127,11 +127,11 @@ prior = dnorm(t, mu0, sigma0)/10 plot(t, p1, type="n") title("N = 5") legend(-2, 0.9, legend=c("Likelihood", "Posterior", "Prior", "Data"), col=c("blue", "orange", "green", "purple"), lty=1:1) +grid() lines(t, p0, lwd = 4, col="blue") lines(t, p1, lwd = 4, col="orange") lines(t, prior, lwd = 4, col="green") lines(t, q, lwd = 4, col="purple") -grid() ## Conjugate priors @@ -158,6 +158,7 @@ for (i in 1:7) { } plot(t, posterior[[7]], type="n", xlab="", ylab="") +grid() lines(t, posterior[[1]], lwd=3, col="red") lines(t, posterior[[2]], lwd=3, col="orange") lines(t, posterior[[3]], lwd=3, col="yellow") @@ -167,6 +168,5 @@ lines(t, posterior[[6]], lwd=3, col="blue") lines(t, posterior[[7]], lwd=3, col="purple") legend(-0.9, 7, legend=c("N = 0", "N = 1", "N = 2", "N = 5", "N = 8", "N = 12", "N = 20"), col=c("red", "orange", "yellow", "green", "turquoise", "blue", "purple"), lty=1:1, lwd=3) -grid() #############