How to use lognrnd?

26 visualizaciones (últimos 30 días)
Yaser Khojah
Yaser Khojah el 11 de Mzo. de 2019
Comentada: Fernanda Suarez Jaimes el 12 de Mzo. de 2020
I'm trying to create a random log-normal distributions for a vector . I have already read the lognrnd document as https://uk.mathworks.com/help/stats/lognrnd.html.and other people who ask a similar question but I'm a bit confused since the document is a bit confusing for me. So, I understand to use lognrnd as R = lognrnd(mu,sigma), both mu and sigma has to be mean and standard deviation of the normal distribution, let us call it Y. The corresponding lognormal distribution of X is Y. To use lognrnd from its given X (lognormal distribution) mean (m) and X variance (v), we should find the mu and sigma first by using these formula as
mu = log((m^2)/sqrt(v+m^2));
sigma = sqrt(log(v/(m^2)+1));
Now, this is clear for me but the confusing part in the document is the following sentence "If X is distributed lognormally with parameters µ and σ, then log(X) is distributed normally with mean µ and standard deviation σ"
Should not be if X is distributed lognormally with parameters m and v since µ and σ represent only the normal distribution?
I have listed what I'm trying to do just to be clear about my understanding and for confirmation about how to estimate random distribution from given mean and standard deviation of the log normal distribution:
m = 14; % mean of the lognormal
std_d = 7; % standard deviaiton of the lognormal
v = std_d^2; % varaiance of the log
mu = log((m.^2)./ sqrt(v+m.^2)); % mu is the normal mean
sigma = sqrt(log(v./(m.^2)+1)); % sigma is the normal standard deviation
R = lognrnd(mu,sigma,10^6,1);
Thanks for your help and reading this.

Respuesta aceptada

Torsten
Torsten el 11 de Mzo. de 2019
Editada: Torsten el 11 de Mzo. de 2019
It is common to say that X is lognormally distributed with parameters mu and sigma if it has the pdf
f(x) = 1/(x*sigma*sqrt(2*pi))*exp(-(log(x)-mu)^2/(2*sigma^2))
If you now calculate the pdf of log(X), you'll see that it equals
g(y) = 1/(sigma*sqrt(2*pi))*exp(-(y-mu)^2/(2*sigma^2))
Thus log(X) is normally distributed with parameters mu and sigma.
To calculate 10^6 random numbers from a lognormally distributed random variable with mean 14 and standard deviation 7, your code from above is correct.
  9 comentarios
Torsten
Torsten el 12 de Mzo. de 2019
Editada: Torsten el 12 de Mzo. de 2019
If X is a continuous real-valued random variable and x is a value in the real numbers, then the cumumlative density function F of the random variable X at x is defined as
F(x) = P(X<=x)
where P(X<=x) is the probability that the random variable X produces a value y that is smaller than or equal to x.
I think you will have to learn the basics of probability theory first before playing around with complicated distributions.
Fernanda Suarez Jaimes
Fernanda Suarez Jaimes el 12 de Mzo. de 2020
Do you know how to run a regression of a time series with lognrnd?

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by