# Prova LIS -- luglio 22 # Es. 1 M=1000 theta=3 mu.0=2 n=10 x.matrice=rnorm(n*M,mu.0,sqrt(theta)) x.matrice=matrix(x.matrice,M,n) x.max=apply(x.matrice,1,max) x.min=apply(x.matrice,1,min) theta.hat=(x.max-x.min)/2 # (a) mean(theta.hat) # 2.7 # (b) mean(theta.hat>2.5) # 0.575 # (c) V=var(theta.hat) B=theta-mean(theta.hat) MSE=V + B^2 MSE # 0.57 # Es. 2 q1=quantile(theta.hat/theta,0.1) q2=quantile(theta.hat/theta,0.9) q1 q2 # L=theta.hat/q2 U=theta.hat/q1 mean(Ltheta) # 0.8 # Es.3 M=1000 mu.0=2 n=10 th0=1 th1=2 x.matrice.0=rnorm(n*M,mu.0,sqrt(th0)) x.matrice.0=matrix(x.matrice.0,M,n) x.max.0=apply(x.matrice.0,1,max) x.min.0=apply(x.matrice.0,1,min) theta.hat.0=(x.max.0-x.min.0)/2 mean(theta.hat.0) W.0=theta.hat.0/th0 mean(W.0) # prob err 1° tipo k.al=2.2 pr.err.1=mean(W.0>k.al) pr.err.1 # 0.061 # potenza x.matrice.1=rnorm(n*M,mu.0,sqrt(th1)) x.matrice.1=matrix(x.matrice.1,M,n) x.max.1=apply(x.matrice.1,1,max) x.min.1=apply(x.matrice.1,1,min) theta.hat.1=(x.max.1-x.min.1)/2 mean(theta.hat.1) W.1=theta.hat.1/th0 mean(W.1) potenza=mean(W.1>k.al) potenza # 0.46 # Es. 4 dati=c(4.85, 1.04, 4.80, 3.26, 4.06, 3.84, 1.61, 2.61, 1.77, 4.02) # (a) IC t.test(dati,alternative="two.sided", conf.level=0.85)$conf.int # (b)-(c) Test t.test(dati,alternative="two.sided", mu=2.3, conf.level=0.94) t = 2.0573, df = 9, p-value = 0.06979 # NON RIFIUTO H0 (per alpha = 0.05) # (d) n=10 qt(1-0.03,n-1) # +/- 2.15 # poiché |t|<2.15 --> accetto H.0