Generating numbers following a lognormal distribution within a specific interval

조회 수: 2 (최근 30일)
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);

답변 (2개)

Paul
Paul 2022년 10월 18일
편집: Paul 2022년 10월 18일
Hi Behrooz,
Shouldn't the relationship be the log of the mean of samples is equal to mu + sigma^2/2 ?
In any case, why would the trunctated distribution satisfy the same relationship as the untruncated?
  댓글 수: 4
Behrooz Daneshian
Behrooz Daneshian 2022년 10월 18일
Paul, thank you very much for taking time to address my question. Let me clarify a little bit. I got a curve from an experiment showing the frequency(number of pores) vs the corresponding pore radious. It means that from this curve, I know how many pores with specific radious exist in the soil. The shape of this curve is bell shaped and according to the literature, we can assume that this curve can be simulated by a lognormal distribution. Now, what I need to do is to define a lognormal distribution within the soil radii range( e.g, minimum pore radious and maximum pore radious).
Paul
Paul 2022년 10월 18일
If you have data from a lognormal distribution, you can try use fitdist to estimate the parameters of the distribution based on the data. I don't know if fitdist can estimate a truncated distribution.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2022년 10월 18일
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
Jeff Miller
Jeff Miller 2022년 10월 23일
  1. 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.
  2. 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.
Behrooz Daneshian
Behrooz Daneshian 2022년 10월 27일
Sorry for the delay. I was thinking about how I could address my question appropriately.
I found that a soil's characteristic follows a lognormal distribution. An experiment is performed on soil in which we would be able to determine the soil's pore radii(assuming that soil's pores are spherical) and the number of pores corresponding to that radius (in other words frequency of each radius). As the plot of the number of pores versus the corresponding radii is a kind of bell-shaped, we conclude that it can be simulated as a lognormal distribution. It should be noted that pore radii are larger than zero(non-negative) and also have a maximum size. Hence, if we are supposed to make a lognormal distribution, we need to truncate that( we do not want to have a radius larger than the maximum pore's radius(rmax), which is known). Within my code, I try to make a lognormal distribution with mu and sigma parameters which need to be optimized by Genetic algorithm. (i.e. they are considered variables in my code, and Genetic algorithm is going to change them until my results almost coincide with the experimental results. The problem is that I made a lognormal distribution( pd=makedist('lognormal',mu,sigma)), but when I truncated the generated distribution (pdt=truncate(pd,0,rmax)) and calculated the mean of natural logarithm of radii and also standard deviation of radii, they are something different than input parameters of mu, sigma. Since we know that if X is lognormally distributed with parameter mu, and sigma, natural logarithm of X is normally distributed with a mean and standard deviation of mu and sigma, respectively. Would you please guide me on this matter? How can I generate a truncated lognormal distribution in an appropriate way?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by