###################### ## Harjoitukset 4 ## ###################### ######### ## 4.4 ## ######### x<-c(1.02,1.41,1.75,2.31,3.42,4.31,9.21,17.4,38.6,392.8) n<-10 theta<-n/sum(log(x)) a<-n*log(theta)-(theta+1)*sum(log(x))+log(0.1)+sum(log(x)) b<-sum(log(x)) fn<-function(theta){n*log(theta)-b*theta-a} curve(fn(x),0,1.5, lwd=2,xlab=expression(theta),main="tehtava 4.4") abline(h=0) abline(v=0.243) abline(v=0.961) #lines(c(0,1.5),c(0,0)) #lines(c(0.243,0.243),c(-25,5)) #lines(c(0.961,0.961),c(-25,5)) uniroot(fn,c(0.1,0.4)) #$root #[1] 0.2429697 # #$f.root #[1] -0.0001355576 # #$iter #[1] 6 # #$estim.prec #[1] 6.103516e-05 uniroot(fn,c(0.7,1)) #$root #[1] 0.9606551 # #$f.root #[1] -7.668373e-07 # #$iter #[1] 4 # #$estim.prec #[1] 6.103516e-05