I try to plot a CDF graph from a file that has 7914 integers ranging from 0 to 594. But when I plot the graph, it just prints a straight line at 1 like this:
Why does it print a straight line? A CDF graph should be curved like this:
Code:
mu = 0;
sigma = 1;
pd = makedist('Normal',mu,sigma);
fileID = fopen('TLSDeliveryTime.txt', 'r');
formatSpec = '%d';
x1 = fscanf(fileID,formatSpec);
fclose(fileID);
y1 = cdf(pd,x1);
figure
semilogx(x1,y1,'LineWidth',2)
set(gca,'xscale','log')
xlabel('Delivery time (ms)');
ylabel('CDF (%)');
ylim([0, 1]);
legend('X.509');
I think you meant to use a cumulative sum to get your cdf.
mu = 0;
sigma = 1;
pd = makedist('Normal',mu,sigma);
fileID = fopen('TLSDeliveryTime.txt', 'r');
formatSpec = '%d';
x1 = fscanf(fileID,formatSpec);
fclose(fileID);
y1 = cumsum(x1) / sum(x1); %cumulative sum, normalized to 1
figure
semilogx(x1,y1,'LineWidth',2)
set(gca,'xscale','log')