in the histogram function using "Normalization", "cdf" to draw out the histogram and cdf does not match, the end of histogram doesn't reach "1"
Show older comments
Here is my code:
data = readtable("owid-covid-data_Subset3.xlsx", opts);
raw_data = data(:,{'location', 'date', 'icu_patients'});
% data scale
march_2020 = isbetween(raw_data.date, datetime(2020,3,1), datetime(2020,3,31));
march_2021 = isbetween(raw_data.date, datetime(2021,3,1), datetime(2021,3,31));
uk = raw_data(march_2021 & ismember(raw_data.location,{'United Kingdom'}), :);
cdfplot(uk.icu_patients);
hold on;
nbins = 20;
h = histogram(uk.icu_patients,nbins,'Normalization','cdf');
xlabel('icu patients scale');
ylabel('frequency');
title('cumulative frequency plot using 20 bins in United Kingdom');

Which step did I make a mistake?
3 Comments
I think we need to see the data to diagnose this problem, so we can replicate exactly what you are seeing. (You can do that using the paperclip icon in the INSERT section of the toolbar.)
The reason I say this is that I get the expected result if I just put in some random data:
data = randn(1000,1);
cdfplot(data);
hold on;
nbins = 20;
h = histogram(data,nbins,'Normalization','cdf');
xlabel('icu patients scale');
ylabel('frequency');
title('cumulative frequency plot using 20 bins in United Kingdom');
Yang
on 9 Oct 2022
the cyclist
on 9 Oct 2022
Glad it worked out!
Accepted Answer
More Answers (0)
Categories
Find more on Noncentral t Distribution 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!
