plot smooth CDF using matlab
Afficher commentaires plus anciens
I would like to make the curve smoother, how is that possible?
clear all; close all;
y = [0.75862069 0.666666667 0.882352941 0.875 0.736842105 0.566666667 0.703703704 0.6 0 0.730769231 0.714285714 0.625 0.675 0.693877551 0.731707317 0.558823529 0.679245283 0.740740741 0.785714286 0.789473684 0.615384615 0.6 0.739130435 0.576923077 0 0.75];
cdfplot(y)
2 commentaires
Wayne King
le 7 Oct 2011
Are you sure that you want to "smooth" an ECDF? I don't think that's a good idea. The ECDF inherently has a staircase appearance and smoothing it distorts the purpose of the ECDF.
What are you trying to gain by smoothing the ECDF?
Dror Dayan
le 7 Oct 2011
Réponses (2)
Wayne King
le 7 Oct 2011
You could do something like this:
[f,xi] = ksdensity(y);
y1 = cumsum(f);
y1 = y1./max(y1);
x = (1:100)/100;
plot(x,y1,'k','linewidth',2);
hold on;
cdfplot(y);
By using ksdensity() to esimate the density.
1 commentaire
Dror Dayan
le 7 Oct 2011
Wayne King
le 7 Oct 2011
That is because the ECDF necessarily jumps, you could just use ecdf()with confidence bounds
[F,X,Flo,Fup] = ecdf(y);
plot(X,F);
hold on;
plot(X,Flo,'r-.'); plot(X,Fup,'r-.');
will be smoother than
stairs(X,F);
Catégories
En savoir plus sur Exploration and Visualization 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!