Creating Random Log Normal Distribution

I'm a bit confused with converting a normal distribution to a log normal and then creating random numbers. I'm not sure if what I'm doing is right or not?
For example, I have the following:
row = 1000;
G = [14000000 3600000 10000000];
Mean = G;
Variance = Mean .* 0.5;
mu = log(Mean.^2./sqrt(Variance+Mean.^2));
sigma = sqrt(log(1+Variance./Mean.^2));
GIP = zeros(row,length(G));
for i = 1:length(G)
R = longhorn(mu(i),sigma(i),[row,1]);
GIP(:,i) = R;
end
LogG = GIP;
The things with this nothing changed. However, if I converted G to G = G/10^6. Then, it will work but I have to convert LogG later to LogG = LogG * 10^6. I do not know why this happens. Does that because the number is too big? please help.

6 件のコメント

dpb
dpb 2018 年 8 月 10 日
What is longhorn?
>> which longhorn
'longhorn' not found.
>>
What do you expect to "change"?
Yaser Khojah
Yaser Khojah 2018 年 8 月 10 日
I expect to see a log normal distribution. Sorry it was a type. I used "Lognrnd"
Jeff Miller
Jeff Miller 2018 年 8 月 11 日
編集済み: Jeff Miller 2018 年 8 月 11 日
What do you mean "nothing changed"? The three columns of LogG have different means and variances, corresponding to what you requested.
Are you unhappy that the frequency distributions are not very skewed? This happens because of the parameters you selected: with some parameters, the lognormal hardly looks skewed at all.
Yaser Khojah
Yaser Khojah 2018 年 8 月 13 日
編集済み: Yaser Khojah 2018 年 8 月 13 日
Hello Jeff, I'm not sure which way is the right way to create a log normal. I will show you two and please let me know the right one.
1)R = lognrnd(mu(i),sigma(i),[row,1]); or
2)R = log(lognrnd(mu(i),sigma(i),[row,1]));
Thank you
Jeff Miller
Jeff Miller 2018 年 8 月 14 日
If you use (1), you will get lognormal random numbers. If you use (2), you will get normal random numbers. Another way to get lognormal random numbers is to use:
R = exp(normrnd(mu(i),sigma(i),row,1));
You should check these to make sure you are getting what you think you are getting:
meanR = mean(R)
stdR = std(R)
figure; histogram(R);
Yaser Khojah
Yaser Khojah 2018 年 8 月 14 日
Thanks Jeff a lot for your help

サインインしてコメントする。

回答 (0 件)

タグ

質問済み:

2018 年 8 月 10 日

コメント済み:

2018 年 8 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by