library(MASS) #(1) n=30 p=3 opak=10000 MSE1=rep(0,opak) MSE2=rep(0,opak) sigma=1 theta=rep(1,p) Sigma=sigma^2* diag(p) set.seed(1234) for (i in 1:opak){ X=mvrnorm(n,theta,Sigma) X_bar=apply(X, 2, mean) #vyberovy prumer theta_hat=(1-(p-2)*sigma^2/n/sum(X_bar)^2)*X_bar #J.-S. odhad MSE1[i]=sum((X_bar-theta)^2) MSE2[i]=sum((theta_hat-theta)^2) } sum(MSE1>MSE2)/opak # podil pripadu, kdy je J.-S. odhad lepsi sum(MSE1