1
$\begingroup$

I believe I'm obtaining overflow errors when randomly sampling from a log-normal distribution with the command:

RandomVariate[LogNormalDistribution[μ, σ], 1]

Specifically, I can obtain an accurate looking distribution with values of $\mu \approx 1$ and $\sigma \approx 1$, but I get significant outliers for values of $\mu > 10$ and $\sigma > 10$. Why would this occur? Isn't it true that the ratio $\dfrac{\mu}{\sigma}$ should govern the probability of obtaining values $\gg \mu$?

What values of $\mu$ and $\sigma$ will give accurate values properly reflecting a random sample from LogNormalDistribution?

$\endgroup$
2
  • $\begingroup$ What definition of "outlier" are you using? A simple "visual test" usually does not work here. Try to generate your data, compute the IQR (interquartile range) and then you can effectively say if the observation is an outler... $\endgroup$
    – Rod
    Commented May 13, 2013 at 6:04
  • 2
    $\begingroup$ Have you compared a histogram of your random variates with the PDF of your distribution? $\endgroup$ Commented May 13, 2013 at 6:07

1 Answer 1

10
$\begingroup$

If $X\sim N\left(\mu ,\sigma ^2\right)$ and $Y=e^X$, then $Y\sim \text{Lognormal}(\mu ,\sigma )$. So, by selecting LogNormalDistribution[10, 10], you are effectively generating values from a $N(10, 100$) distribution (which is a very large variance), and then raising them to $e^X$ ... which will generate deliciously large variates.

To see this:

Here are 6 values generated from a Lognormal, with a given random seed:

SeedRandom[42];
RandomVariate[LogNormalDistribution[10, 10], 6]

{0.886492, 8.54449*10^7, 0.0194899, 1.42431*10^6, 1572.01, 8.07229*10^8}

... and here are the same 6 values generated from the associated Normal, given the same random seed, and raised to $e^X$:

SeedRandom[42];
Exp[RandomVariate[NormalDistribution[10, 10], 6]]

{0.886492, 8.54449*10^7, 0.0194899, 1.42431*10^6, 1572.01, 8.07229*10^8}

In summary: there is nothing wrong with the values being generated ... they are 'safe' /// you are just getting what you asked for.

$\endgroup$
3
  • $\begingroup$ But why would $\mu = 1000$ and $\sigma = 2000$ give me values $>10^{1269}$ when $\mu = 1$ and $\sigma = 2$ barely breaks $500$ for its largest value for $\approx 10^3$ samples? This scaling doesn't seem reasonable? $\endgroup$
    – B.E.
    Commented May 13, 2013 at 6:50
  • 3
    $\begingroup$ Ahh - I think you are doing a plot of the pdf with something like {x, 0, 1000}, and it seems to disappear to 0 for x > 500?? That is a bit deceptive ... the tails are very very very long ... Plot from {x, 1000, 2000} and you will see it is still positive ... forever and ever and ever ... :) $\endgroup$
    – wolfies
    Commented May 13, 2013 at 6:57
  • 1
    $\begingroup$ @B.E.: You increase mu by a factor of 1000, so the output increases by a factor of e^1000. What is so surprising about that? $\endgroup$
    – Aditya
    Commented Jun 19, 2013 at 3:44

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.