###################### ## Harjoitukset 6 ## ###################### ######### ## 6.8 ## ######### ## (a) n<-10 x<-rbinom(100,n,0.3) lf<-function(theta,n,x){x*log(theta)+(n-x)*log(1-theta)} max<-lf(x/n,n,x) max[is.na(max)]<-0 D1<--2*(lf(0.3,n,x)-max) D2<--2*(lf(0.6,n,x)-max) par(mfrow=c(1,2)) hist(D1) hist(D2) ## (b) n<-10 x<-rbinom(500,n,0.3) lf<-function(theta,n,x){x*log(theta)+(n-x)*log(1-theta)} max<-lf(x/n,n,x) max[is.na(max)]<-0 D1<--2*(lf(0.3,n,x)-max) D2<--2*(lf(0.6,n,x)-max) par(mfrow=c(1,2)) hist(D1) hist(D2)