如何绘制CDF图?

时间:2013-12-05 04:31:28

标签: c# java

我想通过从文本文件中读取数据来制作CCDF图。

CCDF 表示互补累积分布函数

我试图搜索CCDF,但我真的不了解它。

所以我不知道如何使用以下数据制作CCDF图。

这是我的数据“file.txt”,即到达间隔时间(秒):

2.824562000
7.914959000
15.838087000
1.013451000
2.813006000
0.424052000
0.146252000
0.166075000
2.298860000
6.393684000
5.341003000
0.005898000
0.009670000
0.453621000
0.068486000
0.039053000

如何通过读取“file.txt”中的数据在Java或C#中绘制此图形? 任何其他编程语言也都可以。

2 个答案:

答案 0 :(得分:2)

您可以使用cumulative distribution function轻松计算和绘制ccdf(互补R)(注意:ccdf = 1-cdf):

x <- c(2.824562, 7.914959, 15.838087, 1.013451, 2.813006, 0.424052, 
       0.146252, 0.166075, 2.29886, 6.393684, 5.341003, 0.005898, 0.00967, 
       0.453621, 0.068486, 0.039053) # sample data

f <- ecdf(x) # this is the cdf
plot(f)

enter image description here

plot(sort(x), 1-f(sort(x)), type="s", lwd=19) # this is the ccdf

enter image description here

答案 1 :(得分:-1)

在提交之前,在windows.form中创建图表

工具箱 - &gt;数据 - &gt;图表,在图表属性中创建系列。

C#:

命名空间:

 using System.Windows.Form;
 using System.IO;
 using System.Data;
 using System.Drawing;
 using System.Windows.Forms.DataVisualization.Charting;
 using System.Drawing.Imaging;

代码段:

 private void button1_Click(object sender, EventArgs e)
    {
   chart1.Visible = true;
      try
        {
        this.Chart1.Series["Series1"].Points.AddXY(0,2.824562000);
        this.Chart1.Series["Series1"].Points.AddXY(1,7.914959000);
        this.Chart1.Series["Series1"].Points.AddXY(2,15.838087000)
        this.Chart1.Series["Series1"].Points.AddXY(3,1.013451000);
        this.Chart1.Series["Series1"].Points.AddXY(4,2.813006000);
        this.Chart1.Series["Series1"].Points.AddXY(5,0.424052000);
        this.Chart1.Series["Series1"].Points.AddXY(6,0.146252000);
        this.Chart1.Series["Series1"].Points.AddXY(7,0.166075000);
        this.Chart1.Series["Series1"].Points.AddXY(8,2.298860000);
        this.Chart1.Series["Series1"].Points.AddXY(9,6.393684000);
        this.Chart1.Series["Series1"].Points.AddXY(10,5.341003000);
        this.Chart1.Series["Series1"].Points.AddXY(11,0.005898000);
        this.Chart1.Series["Series1"].Points.AddXY(12,0.009670000);
        this.Chart1.Series["Series1"].Points.AddXY(13,0.453621000);
        this.Chart1.Series["Series1"].Points.AddXY(14,0.068486000);
        this.Chart1.Series["Series1"].Points.AddXY(15,0.039053000);
        }
      catch
       {
       }
   }

试试这个,我希望有这个帮助。