# Random Number Generation using LogNormalDistribution

I have a problem that I can't seem to figure out on my own due to limited knowledge of mathematics, and I was hoping I could seek help from the community. I would like to use LogNormalDistribution to generate random variables bound by min and max. I fail to do so, and I believe it is due to the way I derive Mean and StandardDeviation. Here is a simplified version of what I want to achieve but using a UniformDistribution instead.

size = 10^4;
bound = {10^-7, 10^-4};

NumberLinePlot @ Interval @ bound


Histogram @ RandomVariate[UniformDistribution @ bound, size]


Based on the above, I can generate random numbers using an UniformDistribution. I have tried to derive a PDF for the above. However, it fails with an error message. Note, I use Win10 and Mathematica 11 for this work.

Show[
Histogram[
RandomVariate[UniformDistribution @ bound, size],
30,
"PDF"
],
Plot[
PDF[UniformDistribution @ bound, x],
{x, bound}
]
]


Skeleton is not a Graphics primitive or directive.

What I would like to be able to do is generate random numbers within a pre-defined boundary using a LogNormalDistribution. I have tried to achieve it by exploring Mean and StandardDeviation functions. However, I fail to achieve the desired outcome. In terms of the Mean, I would like it to remain sloped to the left towards the min. However, it can be anywhere within the first 15% of the CDF.

I do appreciate your help, and thank you for your willingness to assist me with the above.

EDIT 1 - PDF Fix for the above example, based on @kglr contribution

Show[
Histogram[
RandomVariate[UniformDistribution@bound, size],
30,
"PDF"
],
Plot[
PDF[UniformDistribution@bound, x],
{x, ## & @@ bound}
]
]

• try Show[Histogram[RandomVariate[UniformDistribution@bound, size], 30, "PDF"], Plot[PDF[UniformDistribution@bound, x], {x, ## & @@ bound}]]?
– kglr
Dec 30 '19 at 17:21
• Hello, @kglr, and thank you - this actually does work. I am not sure why; I will need to read-up about it. Dec 30 '19 at 17:23
• e.doroskevis, correct syntax is Plot[function[x], {x, a, b}] not Plot[ function[x], {x, {a,b}}] (this is what you have in your code). {x, ##&@@round} (or, equivalently, {x, Sequence @@ round}) gives {x, 10^-7, 10^-4} which is the form Plot wants in its second argument.
– kglr
Dec 30 '19 at 23:59
• Thank you, @kglr. I see what I did wrong. Dec 31 '19 at 0:55

dist = TruncatedDistribution[{xmin, xmax}, LogNormalDistribution[μ, σ]]

(* 15th percentile  *)

You ask for determining the combination of parameters (xmin, xmax, μ, and σ) that result in mean < x15. I don't think there are any combinations of the parameters that will result in that inequality being true.