1
$\begingroup$

I'm a beginner with WM. I actually want to generate two non-overlapping LogNormalDistributions spanning an order of magnetitue with respect means $x = 1$ and $x = 100$

I've plotted the first LogNormalDistribution following the usual approach, and it seems to be (apparently) correct:

LogLinearPlot[PDF[NormalDistributions[1,1],x],{x,10^-3,10^3}]

enter image description here

But the intuitive way seems to be wrong, i.e., LogLinearPlot[PDF[NormalDistributions[10,1],x],{x,10^-3,10^3}] didn't worked as I supposed to work and the resultant combination of the LogNormal is also unaffected by the seconde distribution, change about nothig with respect to the plot presented aboce.

I know that the mean and variance of LogNormal distribution is not as simple as in normal distribution and it requires a moment of thinking regarding to the choose of the proper mu and sigma.

I've tried, wiht the help of other fellow WM user to plot in the following way (with the green ploted being the associated CDF):

Plot[
 {PDF[LogNormalDistribution[1, 0.25], x],
  8 PDF[LogNormalDistribution[3, 0.25], x], 
  CDF[LogNormalDistribution[1, 0.25], x] + 
  CDF[LogNormalDistribution[3, 0.25], x]},
 {x, 0, 200},
 PlotRange -> {-0.01, 2},
 ScalingFunctions -> {"Log", None}
]

enter image description here

But the mans and variances are not as I need and to adjust them I constantly need to change some parameters (for instance, in the plot below, the second PDF generated needed to be multiplied by a factor 8 to be with the same 'height' of the first PDF)

My question is:

Is there an way to generate this associations of distributions with the given parameters (means $x = 1$ and $x = 100$, spanning an oreder of magnitute) in a 'automatic way', without being necessare to change additional parameters by 'handle' (as multiply the PDF by 8)?

Thanks in advance

$\endgroup$
  • $\begingroup$ Do you have a justifiable rationale for adding CDF's together and multiplying PDF's by 8? CDF's have a maximum of 1 and not 2. If one characterizes the lognormal distribution with parameters $\mu$ and $\sigma$, then the mean of a lognormal is $e^{\mu+\sigma^2/2}$ and the variance is $e^{2\mu} e^{\sigma^2} (e^{\sigma^2}-1)$. $\endgroup$ – JimB May 8 at 21:27
  • $\begingroup$ Hi, JimB. Thanks for your feedback. There's no rational reason for multiplying the second PDF by 8. It was the only way to make both PDF have the same 'heigth'. And the fact of adding cdf's is an attemp to reproduce a numerical approach proposed in a paper that I've posted in another post and that you've commented. I'm unfortunately still stuck on attempting to reproduce, but it has been not easy. :( $\endgroup$ – José Augusto Devienne May 8 at 21:38
6
$\begingroup$

I think the issue is not a Mathematica issue but rather a confusion between two different random variables: $X$ and $\log(X)$.

If $X_1 \sim LogNormal(1, 1)$ and $X_{10} \sim LogNormal(10,1)$, then the probability density functions are as follows:

Plot[PDF[LogNormalDistribution[1, 1], x], {x, 0, 25}, 
 PlotRange -> All, ImagePadding -> {{50, 20}, {50, 10}}]

Log normal 1 Plot[PDF[LogNormalDistribution[10, 1], x], {x, 0, 100000}, PlotRange -> All, ImagePadding -> {{50, 20}, {50, 10}}] [Log normal 10]2

Attempting to plot these two densities on the same scale is not very useful (even if you had a 100 inch monitor) as both the horizontal and vertical scales are wildly different.

But if you wanted to plot them on a log-scaled horizontal axis, you'd get

LogLinearPlot[{PDF[LogNormalDistribution[1, 1], x],
  PDF[LogNormalDistribution[10, 1], x]}, {x, 0.01, 100000}, 
 PlotRange -> {{0.01, 100000}, {0, 0.25}},
 PlotStyle -> {Red, {Thickness[0.02], Green}}, 
 PlotRangeClipping -> False]

Lognormal densities on horizontal log scale

This is a correct figure. Just not very useful. Can't see much of any shape for the LogNormalDistribution[10,1] density.

Now you might want to consider a common vertical scaling. But this is starting to sound like the nursery rhyme "There was an old lady who swallowed a fly...." (And you'd be crazy to consider scaling the two densities separately. Yes?)

The simple solution is to consider the log of each of the random variables. Those have normal distributions with respective means 1 and 10.

Plot[{PDF[NormalDistribution[1, 1], logx],
  PDF[NormalDistribution[10, 1], logx]}, {logx, -3, 15},
 PlotStyle -> {Red, {Thickness[0.02], Green}},
 PlotRangeClipping -> False, PlotRange -> All,
 PlotLegends -> {"log(X) ~ Normal(1,1)", "log(X) ~ Normal(10,1)"},
 Frame -> True, FrameLabel -> {"Log(X)", "Probability density"}]

Plot of normal densities

Now the horizontal and vertical axes are on the same scale. The areas under the densities are both 1.

$\endgroup$
  • 1
    $\begingroup$ Nice exposition! +1 $\endgroup$ – ciao May 9 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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