/* Stratified Sampling(LHS) */ new; cls; nn=10000; /* Up to 10000 in Light version of GAUSS */ x=U01ss(nn); library pgraph; graphset; call hist(x,29); proc U01ss(nn); local d,i,U,x,index; /* divide between 0 and 1 into n segments and sample from each segment */ d=1/nn; U=zeros(nn,1); i=1; do while i<=nn; U[i]=(d*i-d*(i-1))*rndu(1,1)+d*(i-1); i=i+1; endo; /* check if the first element is zero or not */ do while U[1]==0; U[1]=d*rndu(1,1); endo; /* randomize the order */ x=zeros(nn,1); i=1; do while i<=nn-1; index=ceil((nn-(i-1))*rndu(1,1)); x[i]=U[index]; if index==1; U=U[2:rows(U)]; elseif index==rows(U); U=U[1:rows(U)-1]; else; U=U[1:(index-1) (index+1):rows(U)]; endif; i=i+1; endo; x[nn]=U; retp(x); endp;