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"
Afficher commentaires plus anciens
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 commentaires
the cyclist
le 9 Oct 2022
Modifié(e) : the cyclist
le 9 Oct 2022
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
le 9 Oct 2022
the cyclist
le 9 Oct 2022
Glad it worked out!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Univariate Discrete Distributions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

