# Soluzioni laboratorio 8 giugno 22 # Compito A # Es. 1 n=10 k=0.2 M=10000 theta=3 a=(1-k)*theta b=(1+k)*theta x.matr=matrix(runif(n*M,a,b),M,n) x.min=apply(x.matr,1,min) x.max=apply(x.matr,1,max) theta.A=0.5*x.min+0.5*x.max # (a) mean(theta.A) # (b) mean(theta.A>2.95) # (c) mean((theta.A-theta)^2) # Es. 2 q1=0.97 q2=1.02 L=theta.A/q2 U=theta.A/q1 mean(Ltheta) # Es. 3 n=30 M=10000 # (a) x.matr.0=matrix(rexp(n*M,1),M,n) W.0=apply(x.matr.0,1,mean) W.0=1/W.0 mean(W.0) mean(W.0>1.3) # (b) x.matr.0=matrix(rexp(n*M,2),M,n) W.1=apply(x.matr.0,1,mean) W.1=1/W.1 mean(W.1<1.3) # (c) potenza=1-mean(W.1<1.3) potenza # Es. 4 data(trees) attach(trees) # (a) length(Height) # (b) length(Height[Height>72]) # (c) mean(Height>66) # (d) shapiro.test(Height) # (e) t.test(Height,conf.level=0.85) # (f) t.test(Height,conf.level=0.95,alternative = "less",mu=75)