/* Empirical Copula (adding randomness) */ /* Notice that the plots of pdf and cdf have no points between the adjacent two points. */ /* We just connect the points just for convenience in the surface plots. */ new; cls; n=100; mu={5 4}; Sig={1 0.9, 0.9 1}; data=mu+rndn(n,2)*chol(Sig); x=data[.,1]; y=data[.,2]; U=Cempr(x,y); print U; library pgraph; graphset; pqgwin auto; _plctrl=-1; xy(U[.,1],U[.,2]); proc Cempr(x,y); local n,xi,yj,index,U; n=rows(x); xi=rankindx(x,1); yj=rankindx(y,1); index=xi~yj; U=index[rankindx(rndu(n,1),1),.]/n-rndu(n,2)/n; retp(U); endp;