Generating numbers following a lognormal distribution within a specific interval
2 views (last 30 days)
Show older comments
Hello everyone. I am trying to generate numbers following lognormal distribution with specific mu and sigma within a specific interval. In other words, I am trying to create a truncated lognormal distribution. Can anyone suggest me a way to do that? I uses the code below , but it does not work since the mean of natural logarithm of generated numbers is not equal to a mu parameter.
rmaxeff=0.5;
rmineff=0.1;
sigma=100;
mu=0.2
pd=makedist('lognormal',mu,sigma);
pdt=truncate(pd,rmineff,rmaxeff);
pors=random(pdt,1,125000);
0 Comments
Answers (2)
Image Analyst
on 18 Oct 2022
You can use fitdist to create a probability distribution for your actual experimental data. Your experimental data should roughly follow the log-normal shape you expect to fit. If it doesn't trace out the full shape of the distribution, and you have only data, say, in one segment on one of the sides, then you can probably still get the parameters of the theoretical curve using fitnlm.
So, now that you have your theoretical fit to a log-normal curve by using fitdist, you can pass that into random to generate a list of random numbers drawn from that distribution (if you need that but it sounds like you don't). If you want to truncate/filter/discard any values generated by that, then you can do that - it's your choice.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
5 Comments
Jeff Miller
on 23 Oct 2022
- Could you explain a bit more what you mean by "frequency of that radius"? Frequencies are usually given either as whole numbers (counts) or as relative frequencies (summing to 1). The frequency values in your file are fractional yet sum to about 4.8, so it is not clear what they represent.
- The plot in the excel file doesn't look lognormal to me. You are already plotting with a log scale for the horizontal axis, and the plotted distribution shape is nowhere near symmetric around its peak, as would be expected for a lognormal plotted on a log scale.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!