{ #function to calulate the CDF of a vector.. #Estimate the CDF at N points on a grid N=250 xx1=seq(min(x),max(x),length=N) xx=c(-999,xx1) source("qgaus.r") source("integrand.r") zz=1:N N1=N+1 for(i in 2:N1){ x1=xx[i-1] x2=xx[i] zz[i-1]=qgaus(x1,x2,x)} zz=cumsum(zz) zz1=pnorm(xx1,mean(x),sd(x)) #if we want to estimate the CDF at the data points xs=sort(x) N=length(x) zz=1:N for(i in 1:N){ zz[i]=qgaus(-999,xs[i],x)} zz1=pnorm(xs,mean(x),sd(x)) #get a quantile.. xp=runif(1,0,1) zzx=c(xp,zz) zord=rank(zzx) qp=xs[zord[1]] qnorm(xp,mean(x),sd(x)) }