Ján Яabčan
Ján Яabčan

Reputation: 773

Java exponential distribution

I need to find a formula for exponential distribution of probability, but I don´t know how to find it. This formula has to have powerful statistical properties (it can´t throw away any result from random to keep indistructed seek of random instance).

I am trying to find formula, which will work in a method like this:

rand.getNextDoubleExpDistrib();

I have this code for now, but according to "input analyser", it doesn´t work correctly

public double getNext() {
    return -lampda * Math.log(rand.nextDouble());
}

Upvotes: 9

Views: 17953

Answers (1)

Florian Prud'homme
Florian Prud'homme

Reputation: 599

You can see this answer : Pseudorandom Number Generator - Exponential Distribution

Here the java code

public double getNext() {
    return  Math.log(1-rand.nextDouble())/(-lambda);
}

Have a nice day

Upvotes: 22

Related Questions