Kod 3.1. Test permutacyjny - statystyki równoważne
par(mfrow=c(3,1))
x1=rnorm(11,8,3)
x2=rnorm(16,6,3)
x=c(x1,x2)
T01=mean(x1)-mean(x2) ### Pierwsza statystyka
T02=mean(x1) ### Druga statystyka
T03=mean(x1)/mean(x2) ### Trzecia statystyka
T1=c(); T2=c(); T3=c()
N=10000
for (i in 1:N)
{
xs=sample(x)
T1[i]= mean(xs[1:11])- mean(xs[12:27])
T2[i]= mean(xs[1:11])
T3[i]= mean(xs[1:11])/mean(xs[12:27])
}
T1st=(T1-mean(T1))/sd(T1)
T2st=(T2-mean(T2))/sd(T2)
T3st=(T3-mean(T3))/sd(T3)
sum(T1>=T01)/N; hist(T1st,breaks=8)
sum(T2>=T02)/N; hist(T2st,breaks=8)
sum(T3>=T03)/N; hist(T3st,breaks=8)