x=c(10.320,9.220,11.700,10.790,9.307,9.525,12.220,11.820,9.553,5.368,4.157,11.730,5.688,7.055,8.113,9.403,11.290,9.870,11.280,11.880,7.969,8.154,8.838,12.260,9.766,7.223,11.440,11.890,7.481,10.490,12.480,7.735,11.660,9.888,10.090,12.160,6.644,8.567,9.216,11.270,13.760,10.000,10.150,9.029,9.091,7.352,11.430,11.150,6.447,11.610) # generated by: x=signif(rnorm(50,10,2),digits=4)
y=c(4.742,9.327,7.274,9.768,11.170,10.870,10.950,6.436,7.509,13.420,8.414,7.401,5.778,8.481,9.438,6.045,7.007,5.952,6.603,5.016,10.030,6.054,7.489,6.860,5.171,5.921,10.920,1.164,6.286,6.525,13.110,9.918,13.400,13.780,16.460,13.030,11.790,12.870,12.980,15.990,13.690,9.017,13.740,15.590,10.460,10.130,13.320,13.580,13.550,14.750) # generated by: y=c(signif(rnorm(30,8,2),digits=4),signif(rnorm(20,13,2),digits=4)) (after several attempts, until the vector did not contain any duplicated value and its Shapiro-Wilk test p-value<0.05)

### Normality check:
shapiro.test(x) # OK for x
shapiro.test(y) # OK for y

### Homoscedasticity check:
library(car)
leveneTest(c(x,y),as.factor(c(rep(1,length(x)),rep(2,length(y))))) # heterogeneous variances

### t-test with heterogeneous variances (comparing the means of sampled populations for y and y):
t.test(x,y) # p-value=0.9005

### Kolmogorov-Smirnov test to compare sampled populations for y and y:
ks.test(x,y) # p-value=0.02171

### Graphical display:

pdf('Illustration_ks_test_histogram_x.pdf',width=6,height=6)
hist(x,n=20,xlim=c(0,20))
par(new=T);plot(x_display,dnorm(x_display,10,2),ty='l',axes=F,xlab='',ylab='')
dev.off()
pdf('Illustration_ks_test_histogram_y.pdf',width=6,height=6)
hist(y,n=20,xlim=c(0,20))
par(new=T);plot(x_display,30*dnorm(x_display,8,2)+20*dnorm(x_display,13,2),ty='l',axes=F,xlab='',ylab='')
dev.off()

