# How do i fit the weibull histogram?

36 vues (au cours des 30 derniers jours)
studentmatlaber le 29 Juin 2021
Commenté : studentmatlaber le 29 Juin 2021
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

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 commentairesAfficher 2 commentaires plus anciensMasquer 2 commentaires plus anciens
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 le 29 Juin 2021
Thank you very much for your help.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Weibull Distribution dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by