Reputation: 773
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
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