Plotting Gamma Distribution, log-normal and histogram

9 visualizaciones (últimos 30 días)
Carlos_conde
Carlos_conde el 18 de Dic. de 2018
Comentada: markus tripolt el 20 de Sept. de 2024
Hello all,
I have witten a piece of code to plot
Gamma Distribution
Log-normal distribution
Histogram (pdf)
from my raw data (droplet diameter).
I am not sure if I have done it correctly because the height of the bins do not match with the fittings (see image). Have I done something wrong? I have also attached the code and data.
Thanks in advance
clear all
close all
%%
load droplet_diameter
%%gamma plot
x= 0:0.01:8;
Y= gamfit(droplet_diameter)
G= gampdf(x,Y(1,1),Y(1,2))
figure
plot(x,G)
%%log
mean=mean(droplet_diameter);
variance= var(droplet_diameter);
sigma= (variance)^0.5
y_lognormal=lognpdf(x,log(mean),sigma)
figure
plot(x,y_lognormal)
hold on
plot(x,G)
hold on
histogram(droplet_diameter,'Normalization','pdf')
  1 comentario
markus tripolt
markus tripolt el 20 de Sept. de 2024
Hi
I think it is too late, but because I am curious.
Could it be because you used for your y_lognormal the log(mean), but the log of the mean (log(mean)) value is not the same like the mean of the log of the indivudial values (mean(log(xi))).
Kind regards
Markus

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 18 de Dic. de 2018
Hmm. I recall answering exactly this same question recently. For a second or so, I wondered if I should expect a spate of such questions. (Did something change when histogramwas introduced?) But you did properly use the histogram method of 'pdf', so the scaling is correct.
That suggests the problem is lack of fit. When I look at the histogram, I'd bet that your actual distribution has a bit heavier upper tail than either a lognormal or a gamma distribution can offer. So the mismatch is in terms of a poorly fitting distribution.
Does that mean your distribution is not in fact either lognormal or gamma in reality? Well, NO real world sampled data ever truly follows any fixed distribution. There is always some amount of crap in there as noise. As well, your distribution is based on far too little data to pin down anything very well. So the true distribution might have been either of those or maybe neither one. At best, you can use a statistcal test to decide which is most probable.
Basically, get better (more) data.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by