cdfplot and ecdf differences

20 views (last 30 days)
Shahil Khan
Shahil Khan on 15 Aug 2021
Commented: Shahil Khan on 15 Aug 2021
Im having some difficulty distinguishing the differences between ecdf and cdfplot. I understand that ecdf calculates it and cdfplot calculates and plots it. The plots they generate are different and produce different stats (mean, median, etc)
My question is, which one is more applicable to use? Are there any differences between these two commands?. Code and graphs to follow.
s = stats_table.Circularity;
histogram(s, 'BinWidth',0.09, ...
[f,x] = ecdf(s);
hold on;
histogram(s, 'BinWidth',0.09, ...
hold off
hold on
[h, stats] = cdfplot(s);
histogram(s, 'BinWidth',0.09, ...
hold off

Accepted Answer

Ive J
Ive J on 15 Aug 2021
Edited: Ive J on 15 Aug 2021
They're the same (see cdfplot doc), the empirical CDF values are supposed to be used in stairs and not plot (smoothed)
rng('default') % For reproducibility
y = evrnd(0,3,100,1);
hold on
[f, x] = ecdf(y);
stairs(x, f, 'r--')
legend('cdfplot', 'ecdf')

More Answers (0)




Community Treasure Hunt

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

Start Hunting!