Why is there a difference between ecdf and cdfcalc plots?
Afficher commentaires plus anciens
Hello,
I tried to plot a complentary cumulative distribution function based on some empircial data set using the ecdf function. Then, I found another possible solution to that specific problem by using the cdfcalc function that also seems to be the basic of the cdfplot function. The reason why I did not use the cdfplot function directly, is the fact that I was looking for a 1-cdf plot as mentioned before. Now that I have implemented both solutions, I get slightly different results as shown in the graph (one is shifted to the right). Since the output of the cdfcalc function returns two vectors of different size, the ycdf vector has to be cropped (according to a question asked in MATLAB Answers, see https://ch.mathworks.com/matlabcentral/answers/8368-plot-complementary-cumulative-distribution). Why is there a difference between both approaches and which one should I use?
%empircial data stored in vector hist
load('hist.mat','hist'); %attached hist.mat-file
hold on
%First approach using cdfcalc
[ycdf,xcdf] = cdfcalc(hist);
xccdf = xcdf;
yccdf = 1-ycdf(1:end-1);
stairs(xccdf,yccdf);
%Second approach using ecdf
[f,x]=ecdf(hist);
fc=1-f;
stairs(x,fc);
hold off

Réponses (0)
Catégories
En savoir plus sur Exploration and Visualization dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!