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
?
Answer
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.
Comments
Post a Comment