Home > Blockchain >  What's the logic behind PERCENTILE.INC Excel function?
What's the logic behind PERCENTILE.INC Excel function?

Time:08-13

I would like to know how does Excel think to calculate the values on the function PERCENTILE.INC. I'm making some studies on Percentile and Quartile, I got the below results:

Percentile Example

How does Excel think to calculate the values on column F?

Here's the formulas I'm using:

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

CodePudding user response:

Short answer - the position of a given percentile when the data is sorted in ascending order, using percentile.inc, is given by

P(N-1) 1

where P is the required percentile as a fraction from 0 to 1 and N is the number of points.

If this expression gives a whole number, you take the value at this position (e.g. percentile zero gives 1, so its value is exactly 22). If it's not a whole number, you interpolate between the value at the position given by the whole number part (e.g. 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. A shorter way of saying this is that you go three-quarters of the way between the two nearest values. So you have:

enter image description here

If you wished to show the logic as an Excel formula, you would have something like this:

=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.

enter image description here

  • Related