MATLAB Answers

How can I generate Conditional Lognormal distribution

2 views (last 30 days)
Vijay on 13 Jul 2020
Commented: Vijay on 14 Jul 2020
Hi Community,
I am trying to create the 10000 sets of random variates of two parameters (a and b) from lognormal distribution with a condition that exp((b-a)/a)*1000 < 5;
a --> mu_a = 0.06, sigma_a = 50;
b --> mu_b = 0.08, sigma_b = 35;
I get to know from documentation for one variable as below but not sure about two varible that follow above condition.
pd = makedist('Lognormal','mu',0.08,'sigma',35);
t = truncate(pd, 0, inf);
r = random(t,10000,1);
Any help would be much appreciated. Thanks in advance.

Accepted Answer

Jeff Miller
Jeff Miller on 14 Jul 2020
Those mu and sigma values don't look right for lognormal distributions. These distributions have only positive values, so they have to be really wildly skewed to have such small means with such large standard deviations. Also, the cutoff of 5 looks too small for these parameters, because a and b will virtually never give a result satisfying the condition. But I think that something like this would work if you adjust the parameters:
mu_a = 0.06; sigma_a = 0.50;
mu_b = 0.08; sigma_b = 0.35;
cutoff = 1020;
nWanted = 10000;
nBatch = 1000;
storedA = [];
storedB = [];
while length(storedA) < nWanted
a = lognrnd(mu_a,sigma_a,nBatch,1);
b = lognrnd(mu_b,sigma_b,nBatch,1);
y = exp((b-a)./a)*1000;
keep = y < cutoff;
storedA = [storedA; a(keep)];
storedB = [storedB; b(keep)];
storedA = storedA(1:nWanted);
storedB = storedB(1:nWanted);
  1 Comment
Vijay on 14 Jul 2020
Thanks Jeff. I realized that the sigma values are too small and corrected to the literature values.
It works.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!