plot smooth CDF using matlab

4 views (last 30 days)
Dror Dayan
Dror Dayan on 7 Oct 2011
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 Comments
Wayne King
Wayne King on 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
Dror Dayan on 7 Oct 2011
trying to do a theoretical cdf, to explain a behaviour and not actual data.

Sign in to comment.

Answers (2)

Wayne King
Wayne King on 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 Comment
Dror Dayan
Dror Dayan on 7 Oct 2011
the problem with that its not accurate enough at the beginning x < 0.2

Sign in to comment.


Wayne King
Wayne King on 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);

Tags

Community Treasure Hunt

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

Start Hunting!