# How do i fit the weibull histogram?

조회 수: 26 (최근 30일)
studentmatlaber 2021년 6월 29일
댓글: studentmatlaber 2021년 6월 29일
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)

댓글을 달려면 로그인하십시오.

### 채택된 답변

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이전 댓글 2개 표시이전 댓글 2개 숨기기
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
studentmatlaber 2021년 6월 29일
Thank you very much for your help.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Weibull Distribution에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by