1

I am trying to generate exponentially distributed random numbers btw 0-100. But when I use the below function my variables is assigned value more than even 200 but they should be btw 0-100. Anybody has any idea?

here is my code;

Random rng3 = new Random(85);
ExponentialGenerator exponentialGenerator = new ExponentialGenerator(0.012, rng3 ); 

and the general usage is ;

public ExponentialGenerator(NumberGenerator<Double> rate,
                            Random rng)

Parameters:

rate - The rate (lambda) of the exponential distribution.

rng - The source of randomness used to generate the exponential values.

Community
  • 1
  • 1
dss
  • 127
  • 1
  • 3
  • 7
  • Which library are you using? – Peter Lawrey Nov 01 '16 at 12:40
  • 1
    you can actually do %100 to bring your answer between 0-99 – Aayush Rohatgi Nov 01 '16 at 12:43
  • 1
    import org.uncommons.maths.random.ExponentialGenerator; – dss Nov 01 '16 at 12:52
  • 1
    http://maths.uncommons.org/ – Erwin Bolwidt Nov 01 '16 at 12:57
  • 2
    Just reject the ones that are higher than 100 (use a while loop to take numbers and reject while > 100) There is no guarantee that the numbers are under a particular upper limit. Taking the modulo like someone else suggested skews your distribution. – Erwin Bolwidt Nov 01 '16 at 13:00
  • 2
    @ErwinBolwidt My initial thought was same as yours, but Aayush Rohatgi got it right. The exponential distribution is memoryless, so the remaining distribution given that you're >= 100 is... exponential with the same lambda! This extends recursively to apply to being greater than any multiple of 100. The only minor nit is that you can get get values > 99 but < 100, not just in the range 0-99 as stated. – pjs Nov 01 '16 at 13:30
  • @pjs I see what you mean. Yes, that makes intuitive sense. (But would be good if you had a reference). Oh and the OP wanted values 0-100, not 0-99, so that looks fine. – Erwin Bolwidt Nov 01 '16 at 13:50
  • 1
    @ErwinBolwidt See Ross's "[intro to probability models](http://store.elsevier.com/Introduction-to-Probability-Models/Sheldon-Ross/isbn-9780124079489/)" for the fact that the remaining life of an exponential is exponential with the same parameterization. That's what probabilists mean when they say the exponential is "memoryless." Only the exponential (continuous) and geometric (discrete) distributions have this property. It's a simple proof if you know CDFs, complementary CDFs, and conditional probability. – pjs Nov 01 '16 at 14:50

0 Answers0