In article <[EMAIL PROTECTED]>, Robert J. MacG. Dawson <[EMAIL PROTECTED]> wrote:
>Linda wrote: >> I want to generate a series of random variables, X with exponential >> PDF with a given mean,MU value. However, I only want X to be in some >> specified lower and upper limit?? Say between 0 -> 150 i.e. rejected >> anything outside this range Does anyone have any ideas how should I do >> that?? > For untruncated exponential RV's the negative-log method of converting >a uniform [0,1] RV is about as good as you can get: > ExpVar = -ln(UnifVar); It is not a good method in the tails, and is much too slow. > It can easily be adjusted to censor to any interval [a,b] by prescaling >onto [exp(-b),exp(-a)]; > TruncExpVar = -ln(exp(-b) + (exp(-a)-exp(-b))*UnifVar); This is efficient but slow, and has the same inaccuracy in the tails if b >> a. It is also unnecessarily complex; equivalent results, are obtained by writing it as TruncExpVar = a - ln(exp(a-b) + (1.0-exp(a-b))*UnifVar); -- This address is for information only. I do not claim that these views are those of the Statistics Department or of Purdue University. Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399 [EMAIL PROTECTED] Phone: (765)494-6054 FAX: (765)494-0558 ================================================================= Instructions for joining and leaving this list, remarks about the problem of INAPPROPRIATE MESSAGES, and archives are available at http://jse.stat.ncsu.edu/ =================================================================