#Data Set   ----------------------------------------------
Q<-c(0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
R<-c(1,0,-1,-2,-3,-4,-5,-6,-7,-8,-9)
#---------------------------------------------------------
difD<-(Q-R); difD
adifD<-abs(difD); adifD
aorderD<-rank(adifD); aorderD
negD<-aorderD[(difD<=0)==TRUE]; negD
posD<-aorderD[(difD>0)==TRUE]; posD
negS<-sum(negD); posS<-sum(posD); negS; posS
nsample<-length(posD)
ST<-min(negS,posS); ST
if(negS==ST){
  nsample<-length(negD)
}
nsample
ntotal<-length(difD)
sortdata<-sort(aorderD); sortdata
sampleMatrix<-combn(x=sortdata,m=nsample); sampleMatrix
critdata<-sort(apply(sampleMatrix,2,sum)); critdata
cset<-which(critdata==ST); cset
p<-max(cset)/length(critdata); p
