简体   繁体   English

PERCENTILE.INC Excel function 背后的逻辑是什么?

[英]What's the logic behind PERCENTILE.INC Excel function?

I would like to know how does Excel think to calculate the values on the function PERCENTILE.INC.我想知道 Excel 如何计算 function PERCENTILE.INC 上的值。 I'm making some studies on Percentile and Quartile, I got the below results:我正在对百分位数和四分位数进行一些研究,我得到了以下结果:

百分位数示例

How does Excel think to calculate the values on column F? Excel 如何计算 F 列的值?

Here's the formulas I'm using:这是我正在使用的公式:

  • =PERCENTILE.INC(B2:B21; 0,75) ==> F2 =PERCENTILE.INC(B2:B21; 0,75) ==> F2
  • =PERCENTILE.INC(B2:B21; 0,50) ==> F3 =PERCENTILE.INC(B2:B21; 0,50) ==> F3
  • =PERCENTILE.INC(B2:B21; 0,25) ==> F4 =PERCENTILE.INC(B2:B21; 0,25) ==> F4
  • =PERCENTILE.INC(B2:B21; 0,00) ==> F5 =PERCENTILE.INC(B2:B21; 0,00) ==> F5

Short answer - the position of a given percentile when the data is sorted in ascending order, using percentile.inc, is given by简短回答 - 当数据使用 percentile.inc 以升序排序时,给定百分位数的 position 由下式给出

P(N-1)+1

where P is the required percentile as a fraction from 0 to 1 and N is the number of points.其中 P 是所需的百分位数,从 0 到 1 的分数,N 是点数。

If this expression gives a whole number, you take the value at this position (eg percentile zero gives 1, so its value is exactly 22).如果这个表达式给出一个整数,你就取这个 position 的值(例如,百分位零给出 1,所以它的值正好是 22)。 If it's not a whole number, you interpolate between the value at the position given by the whole number part (eg for P=0.25 it's 5 and the value at this position is 52) and the value at the position one higher (in this case position 6 so the number is 55), then multiply the difference of the two values (3) by the fraction part (0.75) giving you 2.25 and finally add this to the lower of the two values giving you 54.25.如果不是整数,则您可以在position上插入整个数字部分(例如,p = 0.25的5和Z475757FD492A8BE0EA76AA7683DFEEMEN776883DFEEMENYENEDENENINGY的价值) position 6 所以数字是 55),然后将两个值的差 (3) 乘以小数部分 (0.75),得到 2.25,最后将其添加到两个值中的较低值,得到 54.25。 A shorter way of saying this is that you go three-quarters of the way between the two nearest values.一个更简短的说法是,你 go 是两个最接近的值之间的四分之三。 So you have:所以你有了:

在此处输入图像描述

If you wished to show the logic as an Excel formula, you would have something like this:如果您希望将逻辑显示为 Excel 公式,您将有如下内容:

=LET(P,J3,
range,I$2:I$21,
N,COUNT(range),
position,P*(N-1)+1,
lower,FLOOR(position,1),
fraction,MOD(position,1),
upper,lower+(fraction>0),
lowerValue,INDEX(range,lower),
upperValue,INDEX(range,upper),
difference,upperValue-lowerValue,
lowerValue+fraction*difference)

where I2:I21 contains the data in ascending order.其中 I2:I21 包含按升序排列的数据。

在此处输入图像描述

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

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