why Normal Distribution with Histogram not matching?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Manuel Matus
am 15 Jul. 2021
Bearbeitet: Ive J
am 15 Jul. 2021
Hi, I have a vector of 30189 rows and 300+ columns. All of them with normal distribution. When I try to plot the Normal distribution and histogram of one column, the curve crest is ~2 (max y axis) but when I put the histogram, they reach like 4000 in the y axis making the distribution curve to be way too small to be seen. Why? Below I left figures.
for Distribution_tap=1:pt
pd=fitdist(Cp(:,Distribution_tap),'Normal');
x_values=min(Cp(:,Distribution_tap)):0.01:max(Cp(:,Distribution_tap));
y_value=pdf(pd,x_values);
hold on
plot(x_values,y_value,'LineWidth',2);
histogram(Cp(:,Distribution_tap),30)
end
First figure shows the distribution only
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/685298/image.png)
This is when I add the histogram
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/685303/image.png)
Third figure shows the data is normally distributed
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/685308/image.png)
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 15 Jul. 2021
Use:
histogram(Cp(:,Distribution_tap),30, 'Normalization', 'pdf')
0 Kommentare
Weitere Antworten (1)
Ive J
am 15 Jul. 2021
Bearbeitet: Ive J
am 15 Jul. 2021
This is because histogram shows frequency of your sample, while PDF plots the density. Of course you can change the way histogram behaves:
x = randn(1000, 1);
pd = fitdist(x, 'Normal');
x_values = min(x):0.01:max(x);
y_values = pdf(pd, x_values);
hold on
plot(x_values, y_values, 'LineWidth', 2)
histogram(x, 'Normalization', 'pdf')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!