fitdist should be pdf^-1 but is seems not to return correctly
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Niv Yonat
el 13 de Oct. de 2021
Respondida: John D'Errico
el 13 de Oct. de 2021
x1=[.1:.1:100];
y1 = lognpdf(x1,mu,sigma)
median(y1)
mean(y1)
std(y1)
pd = fitdist(y1.','Lognormal')
% pd<> y1
0 comentarios
Respuesta aceptada
John D'Errico
el 13 de Oct. de 2021
The problem is, you do not understand that evaluating the PDF is NOT the same thing as sampling random numbers from that distribution. This is frequently misunderstod. And yes, the PDF tends to look a lot like the samples you would generate.
fitdist applies to a sample from that ditribution. It is NOT used to fit to values generated from the PDF itself though. (A course in probability and statistics would help, or do some reading.)
But here is an example. I'll use a large sample, so the plot will look good.
X = lognrnd(0,1,10000,1);
histogram(X)
And that sampling of numbers does look like the PDF itself. Now use fitdist.
D = fitdist(X,'lognormal')
And we see a lognormal distribution has been estimated. The parameters are pretty close to what we used to create the sample, but with a sample size of 10000 points, that is to be expected.
Again, some reading would be of use to you. Spend some time understanding what a PDF is, what is the CDF, and how do you generate a random sampling from them, using tools like lognrnd, as well as how you can use tools like fitdist.
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!