简体   繁体   English

计算概率并在Excel中绘制cdf

[英]calculate probability and draw a cdf in Excel

Now I have a column of data like this: 现在我有一列这样的数据:

0.000000
0.000000
0.000000
0.000000
0.024995
0.024996
0.024996
0.024997
0.024997
0.024997
0.024997
0.025004
0.025010
0.025011
0.025996
0.025996
0.025996

First I want to calculate the cumulative probability of these data, and show them in column B, then based on Column A and B, to draw a CDF graph. 首先,我想计算这些数据的累积概率,并在B列中显示它们,然后根据A列和B列绘制CDF图。

Anyone one knows what formula should I use? 任何人都知道我应该使用什么配方?

In the cell to the left of the first entry (B1 in my example), enter the following: 在第一个条目左侧的单元格中(在我的示例中为B1),输入以下内容:

=COUNT(A$1:A1)/COUNT($A$1:$A$17)

Then fill this down the column. 然后在列中填写。

To create the CDF chart, create a scatter plot (with interpolated lines) with x-values =A1:A17 and y-values =B1:B17 . 要创建CDF图表,请创建一个散点图(带插值线),其中x值=A1:A17和y值=B1:B17

Note: 注意:
Since you have several duplicate values at the start of your data, you may want to plot only x-value =A4:A17 and y-values =B4:B17 . 由于数据开头有多个重复值,因此您可能只想绘制x值=A4:A17和y值=B4:B17 This is really depends on the nature of your variable. 这实际上取决于变量的性质。 You can do it this way if it's clear the minimum possible value is zero. 如果明确最小可能值为零,则可以这样做。

I am assuming the numbers you are providing are a Probability Density Function (PDF) and that you want to compute a Cumulative Distribution Function (CDF) from that PDF. 我假设您提供的数字是概率密度函数(PDF) ,并且您想要从该PDF计算累积分布函数(CDF) In that case... 在这种情况下...

B1 would simply be =A1 . B1只是=A1 B2 =B1+A2 , B3 =B2+A3 , etc. Then highlight the data in column B, click the "Insert" Tab, and select a line graph. B2 =B1+A2 ,B3 =B2+A3等。然后突出显示B列中的数据,单击“插入”选项卡,然后选择折线图。 Alternatively you could do in B1 =SUM(A$1:A1) and fill down. 或者你可以在B1 =SUM(A$1:A1)填写并填写。

BTW, CDF's are usually monotonically increasing between 0 and 1. Your PDF doesn't generate a CDF which goes all the way to 1. So, if this is what you're aiming for, you're either not listing all of the data in your PDF, or you need to scale things a little differently. BTW,CDF通常在0到1之间单调递增。您的PDF不会生成一直到1的CDF。因此,如果这是您的目标,那么您要么不列出所有数据在您的PDF中,或者您需要以不同的方式扩展事物。 You could divide each element in column A by the sum of those elements, and that will sum to 1. If all you want is a properly defined CDF, though, you can do it directly by setting B1 =SUM(A$1:A1)/SUM(A:A) and again fill down. 您可以将A列中的每个元素除以这些元素的总和,并且总和为1.如果你想要的只是一个正确定义的CDF,你可以通过设置B1 =SUM(A$1:A1)/SUM(A:A)直接完成它。 =SUM(A$1:A1)/SUM(A:A)再次填写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM