From 678d558ec1ba7f39ed9b42be58e25a9ff67aecbf Mon Sep 17 00:00:00 2001 From: aaaakshat <33050725+aaaakshat@users.noreply.github.com> Date: Wed, 27 Oct 2021 18:24:19 -0400 Subject: [PATCH] Complete visualising likelihood function --- ch08.r | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ch08.r b/ch08.r index b308eee..c966b9f 100644 --- a/ch08.r +++ b/ch08.r @@ -15,6 +15,16 @@ S_grid = mesh$X theta_grid = mesh$Y L = S_grid * log(theta_grid) + (N-S_grid) * log(1-theta_grid) L = t(L) -persp3D(S, theta, L, theta=65, phi=15) +persp3D(S, theta, L, theta=65, phi=15, border="black", lwd=0.3, bty="b2", xlab="S", ylab="θ", zlab="", ticktype="detailed") + +N = 50 +S = seq(from=1, to=N, by=0.1) +theta = seq(0.1, 0.9, (0.1+0.9)/1000) +mesh = meshgrid(S, theta) +S_grid = mesh$X +theta_grid = mesh$Y +L = S_grid * log(theta_grid) + (N-S_grid) * log(1-theta_grid) +L = t(L) +image(S, theta, L, col=rainbow(256), ylim=c(0.9, 0.1)) #############