Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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... –  Rod May 13 '13 at 6:04
2  
Have you compared a histogram of your random variates with the PDF of your distribution? –  J. M. May 13 '13 at 6:07

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
    
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? –  B.E. May 13 '13 at 6:50
3  
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 ... :) –  wolfies May 13 '13 at 6:57
    
@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? –  Aditya Jun 19 '13 at 3:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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