I have a dataset that can be described by a beta probability distribution (alpha = 3.18, beta = 44.87). What I want to do is pick a random value from that beta probability distribution, and depending how many standard deviations away from the mean that value is, I would like to select a second random value from a lognormal distrbution (mu=45.89, sigma=151.595) that is also within the specific standard deviation range.
Summarized: if a value of 0.17 is picked from my beta distrbution (which lies to the right of the mean and is greater than 2nd std, but less than the 3rd std) then I want to pick a random value from my lognormal distrbution that is also to the right of the mean and greater than the 2nd std but less than the 3rd std).
Firstly, I apologize as I am very new to this (1 week in). But the main issue with my code is that I do not properly know how to pick a random value from my lognormal distrbution within a specific standard deviation range. In the below code I have this step simply as the placeholder: Perm = lognrnd(45.89,151.5956,[1 1]). I am also missing one line of code at the end of my for loop which would copy my porRandom value into one column and Perm into a second column after each of the 300 runs, resulting in a 300×2 matrix.
Thanks for taking the time!
number_of_runs = 300; % Run this loop 300 times
porRandom = betarnd(3.1800,44.87,[1 1]); % porRandom = random number generated from a beta distribution within a 1x1 matrix
Perm = (number_of_runs,1); % Generate a value for perm for each loop
for n = 1:number_of_runs; if porRandom <= (mean(porDist) + std(porDist)) OR >= (mean(porDist) - std(porDist)); % if porRandom is within one standard deviation of the mean of a beta distrbution (porDist)
Perm = lognrnd(45.89,151.5956,[1 1]) % then let Perm be equal to a random value within one standard deviation of a defined lognormal distrbution
else if porRandom < (mean(porDist) - (std(porDist) AND > (mean(porDist) - ((std(porDist))*2)); % else if porRandom is within a 1st to 2nd standard deviation range (less than the mean)
Perm = lognrnd(45.89,151.5956,[1 1]) % then let Perm be equal to a random value within a 1st to 2nd standard deviation range (less than the mean) of a defined lognormal distrbution
else if porRandom < (mean(porDist) - (((std(porDist))*2)) % else if porRandom is greater than 2 standard deviations (less than the mean)
Perm = lognrnd(45.89,151.5956,[1 1] % then let Perm be equal to a random value that is greater than 2 standard deviations (less than the mean)
else if porRandom > (mean(porDist) + (std(porDist) AND < (mean(porDist) + ((std(porDist))*2)); % else if porRandom is within a 1st to 2nd standard deviation range (greater than the mean)
Perm = lognrnd(45.89,151.5956,[1 1] % then let Perm be equal to a random value within a 1st to 2nd standard deviation range (greater than the mean) of a defined lognormal distrbution
else porRandom > (mean(porDist) + (((std(porDist))*2)); % else porRandom is greater than two standard deviations (greater than the mean)
Perm = lognrnd(45.89,151.5956,[1 1] % then let Perm be equal to a random value that is greater than 2 standard deviations (greater than the mean)
end
Best Answer