绘制 CDF 图的问题

Problems with plotting CDF graph

我尝试从一个文件中绘制一个 CDF 图形,该文件包含 0 到 594 之间的 7914 个整数。但是当我绘制图形时,它只是在 1 处打印一条直线,如下所示:

为什么打印出来的是一条直线? CDF 图应该像这样弯曲:

代码:

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');

我想你是想用累计和来得到你的 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')