# Prova finale LIS - 2023-2024 - 1 luglio 2024 # ES 1 rm(list=ls()) dati=c(1.09, 0.04, 0.75, 0.60, 1.19, 1.52, 1.19, 0.06, 0.65, 1.21) n=length(dati) n xmed=mean(dati) xmed sig2=1 sig=sqrt(sig2) # IC alpha=0.2 z=qnorm(1-alpha/2) L=xmed-z*sig/sqrt(n) U=xmed+z*sig/sqrt(n) c(L,U) # RIS 0.4247378 1.2352622 # ES 2 rm(list=ls()) dati=c(1.09, 0.04, 0.75, 0.60, 1.19, 1.52, 1.19, 0.06, 0.65, 1.21) t.test(dati,mu=1.5, alternative = "two.sided", conf.level = 0.90) # RIS # stima puntuale 0.83, IC 0.5397732 1.1202268 #p-value = 0.002201 --> si rifiuta H0 (alpha=0.1) # ES 3 rm(list=ls()) al=4 be=3 pgamma(1.5,al,rate=be)-pgamma(0.5,al,rate=be) # RIS 0.59 # qgamma(0.5,al,rate=be) # RIS 1.22 # ES 4 rm(list=ls()) theta=4 n=10 lambda=(theta-1)/2 M=100000 x.mc=rgamma(M*n,1,scale = lambda) x.mc=matrix(x.mc,M,n) stim.mc=2*apply(x.mc,1,mean) + 1 mean(stim.mc) # RIS 4 # ES 5 rm(list=ls()) theta=3 a=0.1 b=2 n=8 M=100000 x.mc=runif(M*n,0,theta) x.mc=matrix(x.mc,M,n) max.mc=apply(x.mc,1,max) L=a + max.mc U=b + max.mc Y=U/L mean(Y) # RIS 1.69 # ES 6 rm(list=ls()) n=10 theta=3 M=100000 x.mc=rpois(M*n,theta) x.mc=matrix(x.mc,M,n) mediane.mc=apply(x.mc,1,median) L=mediane.mc-3*sqrt(mediane.mc/n) U=mediane.mc+3*sqrt(mediane.mc/n) copertura=mean(L<=theta&U>=theta) copertura # RIS 0.97 # ES 7 rm(list=ls()) th0=5 th1=4 n=20 k=3.8 M=100000 # sotto H0 x.mc.H0=rnorm(n*M,mean=0,sd=sqrt(th0)) x.mc.H0=matrix(x.mc.H0,M,n) S2.H0=apply(x.mc.H0,1,var) prob.err.tipo1=mean(S2.H0k) prob.err.tipo2 # beta potenza=1-prob.err.tipo2 potenza # 1-beta # RIS beta=0.418 1-beta=0.481 # ES 8 rm(list=ls()) theta=2 M=100000 x.mc=rgamma(M,1,scale=theta) med.mc=median(x.mc) y.mc=(x.mc-med.mc) mean(y.mc) # RIS 0.62