curve(dbeta(x,1/2,1/2),0,1)

theta <- 0.1
x <- rbinom(1000,100,theta)
ll <- function(theta) {mean(dbinom(x,100,theta,log=TRUE))}
ll(0.1)
values <- rep(100,0)
thetaval <- seq(0,1,length=100)
for (i in 1:100) values[i] <- ll(thetaval[i])
plot(thetaval,values,type="l")


theta <- 0.9
x <- rbinom(1000,100,theta)
ll <- function(theta) {mean(dbinom(x,100,theta,log=TRUE))}
ll(0.9)
values <- rep(100,0)
thetaval <- seq(0,1,length=100)
for (i in 1:100) values[i] <- ll(thetaval[i])
plot(thetaval,values,type="l")

Modifié le: mercredi 2 octobre 2024, 13:53