'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());
}
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
