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 {
        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.

  • 3
    $\begingroup$ 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. $\endgroup$
    – jwimberley
    Aug 5, 2020 at 14:19
  • $\begingroup$ @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. $\endgroup$ Aug 5, 2020 at 14:21
  • 1
    $\begingroup$ The logarithmic series distribution is a completely different beast. $\endgroup$
    – Nick Cox
    Aug 5, 2020 at 15:32

1 Answer 1


Since the log-normal distribution is defined as the distribution of exp(X) where X is a random variable following a normal distribution, you need only find details about how to sample a random number from a normal distribution, and take its exponent.

  • 1
    $\begingroup$ Sorry, but don't you mean "take its logarithm"? $\endgroup$ Aug 5, 2020 at 14:33
  • 6
    $\begingroup$ No, I do not. If If X is log-normally distributed, then log(X) is normally distributed, which is what you are probably thinking of. But I'm describing generating a normally distributed Y=log(X) directly. You couldn't take the logarithm of a normally distributed value, anyways, since the normal distribution has support on the negative real numbers, outside the domain of the logarithm. $\endgroup$
    – jwimberley
    Aug 5, 2020 at 14:38
  • 2
    $\begingroup$ The term lognormal is in a sense backward as a lognormal distribution is, as said, an exponentiated normal. The lognormal is named for what you can do with it -- take logarithms, and you get a normal -- rather than for what you need to do to get it. Although it would be appealing to start all over again with statistical terminology -- the term normal is itself a source of much confusion and misunderstanding -- in practice we have to muddle through and hope that with slow campaigns some usages will fade away and better terms will take their place. $\endgroup$
    – Nick Cox
    Aug 5, 2020 at 15:14
  • 1
    $\begingroup$ Devroye discusses generating from the normal distribution in chapter 9. In the section on normal distributions, an exercise about lognormal distributions (p. 392) mentions this approach, and also hints at a faster/more direct approach to generating lognormal variates. $\endgroup$
    – Chris Haug
    Aug 5, 2020 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.