fitdist should be pdf^-1 but is seems not to return correctly

2 Ansichten (letzte 30 Tage)
x1=[.1:.1:100];
y1 = lognpdf(x1,mu,sigma)
median(y1)
mean(y1)
std(y1)
pd = fitdist(y1.','Lognormal')
% pd<> y1

Akzeptierte Antwort

John D'Errico
John D'Errico am 13 Okt. 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')
D =
LognormalDistribution Lognormal distribution mu = 0.00222268 [-0.017614, 0.0220593] sigma = 1.01197 [0.998137, 1.02619]
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.

Weitere Antworten (0)

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by