Effacer les filtres
Effacer les filtres

monte carlo from lognormal distribution?

5 vues (au cours des 30 derniers jours)
Wesser
Wesser le 5 Jan 2023
Commenté : Jeff Miller le 6 Jan 2023
Hi,
I know how to select from a normal distribution...for example:
Cons = unifrnd(0,800);
But how does one select from a lognormal distribution? For data I have the data sample size, the mean, standard deviation, 1st, 5th, 10th, 25th, 50th, 75th, 90th, 95th, 99th percentiles for the distribution along with the max value. I've read the sections on lognormal distribution and I can't quite sort out how to work my data into the example presented.
Thank you in advance for any help!
  9 commentaires
Wesser
Wesser le 6 Jan 2023
Modifié(e) : Wesser le 6 Jan 2023
How would I go about doing what you suggest?
My advisor is asking if it is possible to assign a distribution around the geometric mean (50th % of 589 as proxi)?
% 1 5 10 25 50 75 90 95 99 100
37 80 120 282 589 759 916 1022 1239 1466
Jeff Miller
Jeff Miller le 6 Jan 2023
@Wesser To do what @Image Analyst suggests, the first step is to take measurements from the histogram of the distribution that you want to use. For each bar in the histogram, determine the value of X at the center of the bar, and the value of Y at the top of the bar. These are the (X,Y) pairs that @Image Analyst refers to in his answer. Note that the scale of the Y values is not important as these can be normalized later, so the heights of the bars can be measured in whatever unit is most convenient (e.g.,. pixels, mm, etc.)

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 5 Jan 2023
You can get random samples from either the blue curve or the red curve if you know the heights of those bars.
Just use inverse transform sampling.
Attached is a demo for Rayleigh.
If you need more help, attach the (x,y) data for the red and blue bar charts.

John D'Errico
John D'Errico le 5 Jan 2023
You have not told me the distribution quantiles yet. So I'll make some up.
P = [1, 5, 10, 25, 50, 75, 90, 95, 99]/100;
Q = logninv(P,2,3);
These are just some made up values. But now we can recover the distribution parameters easily enough. A simple test is to look at this plot:
z0 = norminv(P,0,1);
plot(z0,log(Q),'-o')
If that plot is linear, or reasonably close, then this scheme will work easily enough. In this case of course, the plot is exactly linear, since I constructed the data from a known lognoormal distribution.
P1 = polyfit(norminv(P,0,1),log(Q),1);
Mu = P1(2)
Mu = 2.0000
Sigma = P1(1)
Sigma = 3.0000
Now if you want to generate a sample from that distribution, you can use those distribution parameters.
lognsample = lognrnd(Mu,Sigma,[1,5])
lognsample = 1×5
0.0081 6.4422 109.7892 9.9966 3.1125
If the plot I showed above (for your data) is not linear or close to a straight line, then your distribution may not be lognormal.
  1 commentaire
Wesser
Wesser le 6 Jan 2023
Thank you John. I'm going to consult with my advisor on how to proceed. I appricaite your example.

Connectez-vous pour commenter.

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by