views:

671

answers:

6

Hi all,

I am looking for a source for the processing steps behind Excel functions. For example I would like to know how exactly the function PERCENTILE(array, percentile) works. Having embarked upon a quick search I couldn't find anything really, so was wondering if anyone here knew of a better source.

The reason for my search is that I know that Excel uses a different method to calculate percentiles than I would have learnt, and would like to see what this is. I also then will need to mimic this method in an application.

Hope this falls under the scope of "programming related"!

Any help would be greatly appreciated

A: 

You could just use simple cases to work out it's behaviour and try and replicate it. I doubt there is much info about this type of stuff as obviously it's closed source.

Rich Bradshaw
A: 

The code you are describing makes up part of the code of Excel - I doubt MS wants you to see it, so you may find this difficult.

Galwegian
A: 

The percentile function algorithm is not listed. However you can find the algorithm for quartile function which is similar to percentile. It can be found at http://support.microsoft.com/default.aspx?scid=kb;en-us;Q103493

Dheer
+2  A: 

This comes from the Excel Help file (Excel 2002/XP)


PERCENTILE

Returns the k-th percentile of values in a range. You can use this function to establish a threshold of acceptance. For example, you can decide to examine candidates who score above the 90th percentile.

Syntax

PERCENTILE(array,k)

Array is the array or range of data that defines relative standing.

K is the percentile value in the range 0..1, inclusive.

Remarks

If array is empty or contains more than 8,191 data points, PERCENTILE returns the #NUM! error value. If k is nonnumeric, PERCENTILE returns the #VALUE! error value. If k is < 0 or if k > 1, PERCENTILE returns the #NUM! error value. If k is not a multiple of 1/(n - 1), PERCENTILE interpolates to determine the value at the k-th percentile.


It seems to cover what I thought to be the most important question, which is that Excel will interpolate over gaps. IIRC, the interpolation is performed on a straight-line basis between the two adjacent points, confirmed, I think, by this quick test:

      A     B      C    D
 1     1      0%    1    =PERCENTILE($A$1:$A$6,B1)
 2     2     20%    2    =PERCENTILE($A$1:$A$6,B2)
 3     3     40%    3    =PERCENTILE($A$1:$A$6,B3)
 4     4     60%    4    =PERCENTILE($A$1:$A$6,B4)
 5     5     80%    5    =PERCENTILE($A$1:$A$6,B5)
 6     6    100%    6    =PERCENTILE($A$1:$A$6,B6)
 7     
 8           10%    1.5  =PERCENTILE($A$1:$A$6,B8)
 9           11%    1.55 =PERCENTILE($A$1:$A$6,B9)
10           12%    1.6  =PERCENTILE($A$1:$A$6,B10)
Mike Woodhouse
+2  A: 

Hi please go through

http://en.wikipedia.org/wiki/Percentile

and at end, they explained algorithm used by excel.

lakshmanaraj
+1  A: 

http://www.wessa.net/quart.wasp

Excel 2007 appears to use method 5. Empirical Distribution Function - Interpolation. I believe earlier versions may have used a diff method. http://www.xycoon.com/method_5.htm

jhall251