I've tried to plot cdfcurves of my data by calling cdfplot(x)
function. Here is part of my code:
figure;
for i=1:length(num_curves)
h = cdfplot(10*log10(plot_vec1(:,i)));
set(h,'Linewidth',2,'Color',cc(i,:),'Linestyle','-');
hold on
%set(color, cc(i,:));
end
Unfortunately the result I get is very confusing.
Yellow and purple curves are starting from nonzero value, but CDF curve should always start from zero! Can anyone give me some suggestions? I've tried to plot yellow curve by itself, but it is still 'biased'. Thank you for help!
The problem is that your data plot_vec1
contains zeros. Those zeros are transformed to -inf
when you transform to dB with 10*log10()
. Then cdfplot
sees that the minimum finite value (about -67
in your yellow curve) has many samples (with value -inf
) below it. That's why it gives a non-zero accumated probability there.
For example, compare these two figures
Normal case, all values are finite:
cdfplot([1 2 3 4 5 6])
Some values are -inf
:
cdfplot([-inf -inf 3 4 5 6])
Here the minimum finite value, which is 3
, has a 0.33
cumulative probability shown on the vertical axis. That's because 2 of the 6 samples are - inf
and are thus below 3
:
Possible workarounds: remove those zeros before applying the logarithm, or replace the resulting -inf
by a very small value in dB, such as -100
.