频率表的Excel公式

时间:2018-07-08 17:08:36

标签: excel frequency

任何简单的Excel公式都可以计算频率表中数据的平均值(模式,标准偏差,...):

value    frequency
5         3
8         5
4         11
....      ....

谢谢

4 个答案:

答案 0 :(得分:3)

您可以通过传递以下命令来使用Excel的本机统计功能(必须通过 ctrl + shift + enter 提交):

IF(Table1[frequency]>=TRANSPOSE(ROW(INDIRECT("1:"&MAX(Table1[frequency])))),Table1[value])

enter image description here

答案 1 :(得分:3)

为了使用本机统计工作表功能,您将不得不将频率表扩展为数字数组。尽管google电子表格具有textjoin和split函数来创建数组,但是excel没有这种本机功能。

使用用户定义函数将频率表扩展为其元素的数组。

Function freqArray(rngV As Range, rngF As Range, _
                   Optional bSorted As Long = 0)
    'usage: =freqArray(<value_range>, <frequency_range>, <-1 descending; 0 no sort (default); 1 ascending> 

    Set rngV = Intersect(rngV, rngV.Parent.UsedRange)
    Set rngF = rngF.Cells(1).Resize(rngV.Rows.Count, rngV.Columns.Count)

    Dim i As Long, j As Long, k As Long
    ReDim fa(1 To rngV.Rows.Count * Application.Sum(rngF))

    For i = 1 To rngV.Cells.Count
        For j = 1 To rngF.Cells(i).Value
            k = k + 1
            fa(k) = rngV.Cells(i)
        Next j
    Next i

    If bSorted Then
        Dim tmp As Variant, bDescending As Boolean
        bDescending = CBool(bSorted < 0)
        For i = LBound(fa) To UBound(fa) - 1
            For j = i + 1 To UBound(fa)
                If CBool(fa(i) < fa(j) And bDescending) Xor _
                   CBool(fa(i) > fa(j) And Not bDescending) Then
                    tmp = fa(j): fa(j) = fa(i): fa(i) = tmp
                End If
            Next j
        Next i
    End If

    freqArray = fa

End Function

enter image description here

答案 2 :(得分:2)

平均:

=SUMPRODUCT(A2:A4*B2:B4)/SUM(B2:B4)

enter image description here

答案 3 :(得分:2)

因此,遵循与@Gary学生模式类似的模式,(样本)方差Var1为

=(SUMPRODUCT(A2:A4^2*B2:B4)-SUMPRODUCT(A2:A4*B2:B4)^2/SUM(B2:B4))/(SUM(B2:B4)-1)

(样本)标准偏差SD1是其平方根。

对方差和SD使用备用公式:

some sripts

再次借用另一个答案@ jblood94,可以得到方差Var2和标准差SD2,

=VAR.S(IF(TRANSPOSE(ROW(INDEX(A1:INDEX(A:A,MAX(B2:B4)),0)))<=B2:B4,A2:A4,""))


=STDEV.S(IF(TRANSPOSE(ROW(INDEX(A1:INDEX(A:A,MAX(B2:B4)),0)))<=B2:B4,A2:A4,""))

enter image description here

很明显,因为这会生成一个2d数组(用于示例数据的3行11列),所以它比VBA解决方案需要更多的存储空间。