source('https://myweb.uiowa.edu/pbreheny/7110/f20/notes/fun.R')
source('https://myweb.uiowa.edu/pbreheny/7110/f20/notes/radford-neal.R')

# Inconsistent MLE
set.seed(1)
x <- gen(2, 10)
x[10] <- 0.325
theta <- sort(c(seq(-1, 3, len=99), x))
l <- sapply(theta, function(a) log.lik(x, a))
plotL(theta, exp(l)); abline(v=2, col='gray', lty=2, lwd=2)
plotl(theta, l); abline(v=2, col='gray', lty=2, lwd=2)
x <- gen(2, 40)
theta <- sort(c(seq(-1, 3, len=99), x))
l <- sapply(theta, function(a) log.lik(x, a))
plotL(theta, exp(l-max(l))); abline(v=2, col='gray', lty=2, lwd=2)
plotl(theta, l); abline(v=2, col='gray', lty=2, lwd=2)
theta <- seq(1.5, 3.0, len=99)
l <- sapply(theta, function(a) log.lik(x, a))
plotL(theta, exp(l-max(l))); abline(v=2, col='gray', lty=2, lwd=2)
plotl(theta, l); abline(v=2, col='gray', lty=2, lwd=2)
