I’m trying to generate 10000 random numbers taken from a log normal distribution who’s associated normal distribution has mean = 0.3 and std. dev. = 0.05 in MATLAB.
I’m using the built in lognrnd function.
My attempt is to do:
R = lognrnd(0.3,0.05,10000,1)
However, when I plot the histogram of R using hist(R), the associated plot is normal, not log normal.
Where am I messing up? If the mean = 0.3 and std. dev. = 0.05 of the normal distribution, shouldn’t the generated log normal numbers have a mean = 0.3 and std. dev = 0.05?
The numbers you generate are actually from log-normal distribution. Plot just looks similar for your parameters. Compare
hist(R)withhist(log(R))– the shape is pretty much the same.As for mean and deviation, take a look at lognrnd documentation:
hence generated numbers are expected to have different mean and deviation.
EDIT: I’m not sure if Matlab lets you specify lognormal distribution parameters directly, but you can derive one set of the parameters from the other. Assuming M and V are desired parameters of lognormal variable, you can calculate
muandsigmausing following formulas:See wikipedia for opposite conversion.