0

I have a known parameters mu and sigma for lognormal distribution, and I don not know the lower and upper bound or interval for the random variable. I know (Random.nextGaussian() * sigma ) + mu used to generat random variat for normal distribution with mu and sigma parameters. However, how can I generate a random number from the lognormal distribution with known mu and sigma using Java? Thank you.

Cettt
  • 11,460
  • 7
  • 35
  • 58
John
  • 107
  • 1
  • 14

1 Answers1

1

Use apache commons math to create a LogNormalDistribution.

    Double mu = 0.0;
    Double sigma = 0.0;
    LogNormalDistribution logNormal = new LogNormalDistribution(sigma, mu);
    System.out.println("Random Value : " + logNormal.sample());
Ulises
  • 9,115
  • 2
  • 30
  • 27