probability density function normalization
Show older comments
I would like to illustrate the probability density function and the histogram of a data set. This is the code I used so far:
clc;
xValues = 0:0.001:0.5;
for i = [21,24]
figure;
grid on;
hold on;
% newcolors = [0 0 0; 1 0 0; 0.3010 0.7450 0.9330; 0.9290 0.6940 0.1250];
% colororder(newcolors);
for j = 0:c:(3*c) %alle 3 Messarten vergleichen
% histfit(T_mean{i+j},20,'kernel')
histogram(T_mean{i+j},20,'Normalization','pdf','DisplayStyle','stairs');
pd = fitdist(T_mean{i+j},'Kernel');
y = pdf(pd,xValues);
plot(xValues,y)
% ksdensity(T_mean{i+j})
end
hold off;
end
where c is 24. The T_mean is a table composed of 4 tables with length of 24, which are 24 different sets of data. In this case I only need 21 and 24, which each contain a vector. With this code, the probability density function and the histogram have the same normalization. But the y-axis is do large. The area under the pdf should be smaller than 1, so the y-axis could be read in %. Perhaps I don't understand the pdf function correctly. Here is a picture of one of the graph outputs:

The pdf seems to have different definitions in Matlab:
and
Matlab seems to use the second one in this case.
How can I normalize the histogram as 'probability' but also normalize the pdf the same way?
Accepted Answer
More Answers (0)
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!