开发者

Plot smooth cumulative distribution function using MATLAB

How is it possible to make the following cumulative distribution function (CDF) curve smoother?

Here's my code, using cdfplot:

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.69开发者_如何学C3877551 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)

The plot looks like:

Plot smooth cumulative distribution function using MATLAB


data = [2 1 4 2 3];
sdata = sort(data);
plot(sdata,(0.5:length(sdata))./length(sdata),'-');


data = [1 2 2 3 4];
dsum = sum(data);
normalized_data = data/dsum;

cdf = data;

for i = 1:length(data)
    cdf(i) = sum(normalized_data(1:i));
end

plot(cdf);

Is this what you are looking for?


You can use the function ecdf:

[f,x] = ecdf(y);
plot(x,f);


There is one method. But I consider it as a kind of cheating. Use it with your own responsibility. you can try cdfplot([x,x+a*randn(length(x),1)]). You can play with parameter a, but I suggest you to use value around 0.5. Cheers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜