Creating Random Log Normal Distribution
조회 수: 2 (최근 30일)
이전 댓글 표시
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
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);
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!