0

I want to generate random numbers on bounded exponential distribution in Java but the formula x = log(1-u)/(−λ) (Here u is a uniform random number between [0,1) ) does not generate bounded exponential random number.

Please let me know how can I generate a bounded exponential distribution based random number in JAVA.

Iamat8
  • 3,646
  • 8
  • 22
  • 29
user2358262
  • 197
  • 2
  • 11
  • What do you mean by bounded? Your quantile function is correct. – Bathsheba Oct 06 '15 at 15:24
  • By Bounded I mean to say all generated number should lie in range of 1-100. – user2358262 Oct 06 '15 at 15:29
  • Before I wade in with something pragmatic, what are you wanting to use the random numbers for? – Bathsheba Oct 06 '15 at 15:45
  • There is a set of experiment to be run for research on hadoop on basis on the exponential distribution based random number having a mean of 50 and number lying in the range of 1 to 100. – user2358262 Oct 06 '15 at 16:30
  • Hum. That's tricky. I was going to suggest that you apply the quantile function then discard the outliers. But that suffers from two effects: your mean will go off, and you'll introduce statistical bias since you should never discard random numbers. I think you need to start from scratch: write out the cdf for the special distribution that you want, then construct the quantile function from that. You might get away with an affine transformation of p and a recalibration of lambda to recover the correct mean. Unfortunately that's a couple of hours work for me and I don't have the time. – Bathsheba Oct 06 '15 at 16:50
  • Try the mathematics site? – Bathsheba Oct 06 '15 at 16:50
  • I will look into it. Thanks @Bathsheba – user2358262 Oct 06 '15 at 22:43

1 Answers1

0

Wrt your question, you could try to rescale your U(0,1) rng, say for range [A...B], L is lambda

a = 1.0 - exp(-A*L); // so that log(1-a)/(-L) = A;
b = 1.0 - exp(-B*L); // so that log(1-b)/(-L) = B;

// now sampling 
u = a + (b - a) * Rng();
v = log(1-u)/(-L);

In your case A = 1, B = 100

BTW, u and 1-u have the same distribution, so you could use log(u) instead of log(1-u), saves you a substraction

Severin Pappadeux
  • 15,291
  • 3
  • 27
  • 51
  • A problem with this approach is that `L` will no longer be the mean of the distribution. `L` requires rescaling too. – Bathsheba Oct 07 '15 at 06:56
  • @Bathsheba that is correct, but I cannot find in the original question the desire to preserve `L` as a mean. From the other hand, `L` still has meaning of rate in my approach – Severin Pappadeux Oct 07 '15 at 15:10