# Generating numbers following a lognormal distribution within a specific interval

5 visualizaciones (últimos 30 días)
Behrooz Daneshian el 18 de Oct. de 2022
Comentada: Behrooz Daneshian el 27 de Oct. de 2022
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 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

Paul el 18 de Oct. de 2022
Editada: Paul el 18 de Oct. de 2022
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 comentariosMostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
Behrooz Daneshian el 18 de Oct. de 2022
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 el 18 de Oct. de 2022
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.

Iniciar sesión para comentar.

Image Analyst el 18 de Oct. de 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 comentariosMostrar 3 comentarios más antiguosOcultar 3 comentarios más antiguos
Jeff Miller el 23 de Oct. de 2022
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 el 27 de Oct. de 2022
Sorry for the delay. I was thinking about how I could address my question appropriately.

Iniciar sesión para comentar.

### Categorías

Más información sobre Noncentral t Distribution en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by