How do i fit the weibull histogram?
29 ビュー (過去 30 日間)
古いコメントを表示
Hello to everyone. I'm plotting a histogram of a data I have. This distribution is most similar to the "weibull distribution". When I fit the graph with the histfit command, it does not match the graph. I found the scale and shape values of the weibull distribution with the fitdist command. I tried plotting a manual weibull distribution to fit the histogram, but it still doesn't match the histogram. I will share all the outputs with you. This is the code I wrote to draw it manually. I would be very grateful if you could tell me how to properly fit the histogram.
histfit(signalhist_poz,1000,'weibull');
histogram(signalhist_poz)
fitdist
Weibull distribution
A = 0.141626 [0.140708, 0.14255]
B = 0.652068 [0.649942, 0.654202]
PD=makedist('Weibull','a',0.141626,'b',0.652068)
X = 0:.01:1.2;
pdf_weibull = pdf(PD,X);
histogram(signalhist_poz);
hold on
plot(X,pdf_weibull,'LineWidth',2)
0 件のコメント
採用された回答
TADA
2021 年 6 月 29 日
The PDF you calculated should be normalized to the area of the histogram first.
Here's how histfit does it more or less:
pd=makedist('Weibull','a',0.141626,'b',0.652068) ;
n = 1000;
signalhist_poz = PD.random(n, 1);
X = 0:.01:1.2;
pdf_weibull = pdf(PD,X);
nbins = 100;
figure(1);
clf();
h = histogram(signalhist_poz, nbins);
binedges = h.BinEdges;
hold on
plot(X,pdf_weibull,'LineWidth',2);
% Normalize the density to match the total area of the histogram
binwidth = abs(binedges(2)-binedges(1)); % Finds the width of each bin
% this is where the magic happens
area = n * binwidth;
y = area * pdf_weibull;
figure(2);
clf();
histogram(signalhist_poz, 100);
hold on;
plot(X,y,'LineWidth',2)
4 件のコメント
TADA
2021 年 6 月 29 日
If this doesn't help, it might be a good idea to post a new question. That way, people may find their answer next time they encounter similar problem, and new people will notice your question, so you can attract the attention of the forum experts
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!