MS EXCEL:从一组数字中返回四分位数和值


0

我正在尝试计算值数组的范围,我在Excel中使用了QUARTILE函数,但我似乎无法理解它 - 我将如何返回第一个四分位数的界限,第二个四分位数,第三四分位数和第四四分位数?我想这样做的原因是绘制一个框图而不显示异常值,因为它们使图形不可读。

我正在使用的功能是:

=QUARTILE(C2:C6231,0)
=QUARTILE(C2:C6231,1)
=QUARTILE(C2:C6231,2)
=QUARTILE(C2:C6231,3)
=QUARTILE(C2:C6231,4)
  • 0显示最小值(包括异常值)
  • 图1显示了第二四分位数的下限
  • 图2显示了中值
  • 图3显示了第三四分位数的上限
  • 4显示最大值(包括异常值)

这里有什么我想念的吗?


你的意思是说Ubound&Lbound?
Rajesh S

@RajeshS,我如何使用Ubound和Lbound查找Quartile边界?
PavKR

我可以建议你找到除Quartile以外的低和高中位数的公式,它会对你有用吗?
Rajesh S

根据定义,四分位数包括所有数据,包括异常值。所以你不能使用四分位来消除异常值。您需要使用标准偏差之类的东西来识别异常值或设置限制。
fixer1234

Answers:


1

首先,您需要确定异常值所属的范围。使用正态分布,您可以选择与所需平均值相差多少标准偏差。一个标准偏差应该包含68%的人口,两个应该包含95%,三个应该包含99%。既然你有异常值,我会使用1.5标准差,因为它应该占总人口的大约86%; 比平均值高43%,比平均值低43%。在excel中,这可以使用公式来完成: =MEDIAN($A:$A)-1.5*STDEV.S($A:$A)=MEDIAN($A:$A)+1.5*STDEV.S($A:$A)

这为您提供了上限和下限。上限是第四个四分位数的上限,下限是第一个四分位数的下限。知道这一点,你可以使用它们之间的差异来计算内部界限。

Upper Bound - Lower Bound = Range
Range / 4 = Interval
Lower Bound = Lower bound of 1st Quartile
Lower Bound + Interval = Upper bound of 1st quartile, Lower bound of 2nd quartile 
Lower Bound + 2*Interval = Median, Upper bound of 2nd Quartile, Lower bound of 3rd quartile
Upper Bound - 2*Interval = Median, Upper bound of 2nd Quartile, Lower bound of 3rd quartile
Upper Bound - Interval = Upper bound of 3rd quartile, Lower bound of 4th qartile
Upper Bound = Upper Bound of 4th qartile

这个的vb代码如下所示:

Public Sub Quartiles()
Dim Stdev, UpperBound, LowerBound, Interval As Double
Dim q1, q2, q3, q4 As String
Dim wf As WorksheetFunction
Stdev = WorksheetFunction.StDev_S(Selection)
UpperBound = WorksheetFunction.Median(Selection) + (1.5 * Stdev)
LowerBound = WorksheetFunction.Median(Selection) - (1.5 * Stdev)
Interval = (UpperBound - LowerBound) / 4
LowerBound = WorksheetFunction.Round(LowerBound, 3)
UpperBound = WorksheetFunction.Round(UpperBound, 3)
Interval = WorksheetFunction.Round(Interval, 3)
q1 = Str(LowerBound) + "," + Str(LowerBound + Interval)
q2 = Str(LowerBound + Interval) + "," + Str(LowerBound + 2 * Interval)
q3 = Str(UpperBound - 2 * Interval) + "," + Str(UpperBound - Interval)
q4 = Str(UpperBound - Interval) + "," + Str(UpperBound)
MsgBox ("Q1: " + q1 + vbNewLine + "Q2: " + q2 + vbNewLine + "Q3: " + q3 + 
vbNewLine + "Q4: " + q4)
End Sub
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.