plot smooth CDF using matlab
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Wayne King
2011-10-7
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?
回答(2 个)
Wayne King
2011-10-7
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.
Wayne King
2011-10-7
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);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!