gg <- c(rep("a",10),rep("b",3),letters[5:9])
theta.likelihood(theta=2,gg)
optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=gg)
a <- untb(n=1000,gens=1000,prob=1e-3,start.mono=TRUE)
optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=a)
## Fails due to numerical overshoot
optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=a,give.log=TRUE)
## Compare the true value of 2 (=2*1e-3*1000). Not bad
Run the code above in your browser using DataCamp Workspace