Generating random numbers that are log-normally distributed

Even though I don't quite understand why and how this works, I appreciate how simple it is to generate a set of numbers which are Poisson distributed:

public static int getPoisson(double lambda) {
double l = Math.exp(-lambda);
double p = 1.0;
int k = 0;

do {
k++;
p *= Math.random();
} while (p > l);

return k - 1;
}


This "generating" function is basically from this book were I also find generating functions for the binomial and the geometric distribution.

But I did not find a simple generating function for the log-normal distribution. Either the author calls this distribution the "logarithmic series distribution" (then the generating function would not be simple), or it is missing. In the latter case I am looking for some pseudo-code.

• You can probably find details about how to create a random number generator for a normal distribution; then you just have to take the exponent of it. – jwimberley Aug 5 '20 at 14:19
• @jwimberley: do you want to post your comment(s) as an answer? Better to have a short answer than no answer at all. Anyone who has a better answer can post it. – Stephan Kolassa Aug 5 '20 at 14:21
• The logarithmic series distribution is a completely different beast. – Nick Cox Aug 5 '20 at 15:32