Your method looks like a naive reimplementation of integration, and won't work so well for distributions that have the great majority of the probability mass concentrated in a small fraction of the sample space. I was hoping for something that would retain the adaptability of integrate().

(Ted Harding) wrote:

If that's all you want to do, then a very straightfoward approach should
be OK. I illustrate with a truncated normal distribution on [-1,1]:

 x <- (-1)+(0.001*(0:2000));pdf<-dnorm(x); pdf<-pdf/(sum(pdf)*0.001)
 CDF<-cumsum(pdf)*0.001
 plot(x,pdf,ylim=c(0,1),type="l");lines(x,CDF)

Quantiles:
N=10;e<-CDF[1];
for(i in (0:10)){
j<-max(which(CDF<=i/N+e));print(c(x[j],CDF[j]))
}



______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to