First, get your variables proper names; perhaps i will correct it then.(Feel free to correct if theres a problem with my simulations. R code :
Code:yz<-list() pz<-rep(0, 100000) for (i in 1:100000){ xy<-seq(1:16) yz[i]<-sum(sample(xy)[1:8]<7) kk<-sample(xy) for (j in 1:16) { if (j %% 2==1) { if ((kk[j] == 1) && (kk[j+1] == 2)) { pz[i]<-1 } else if ((kk[j] == 2) && (kk[j+1] == 1)) { pz[i]<-1 } else if ((kk[j] == 2) && (kk[j+1] == 3)) { pz[i]<-1 } else if ((kk[j] == 3) && (kk[j+1] == 2)) { pz[i]<-1 } else if ((kk[j] == 3) && (kk[j+1] == 1)) { pz[i]<-1 } else if ((kk[j] == 1) && (kk[j+1] == 3)) { pz[i]<-1 } } } } sum(pz)/100000 sum(yz==6)/100000+sum(yz<1)/100000 sum(yz>5)/100000+sum(yz<2)/100000 sum(yz>4)/100000+sum(yz<3)/100000