Search Postgresql Archives

Re: How do work tercile, percentile & funcion percentile_cont() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-04-22 10:00:49 +0200, PALAYRET Jacques wrote:
> From a table x(c1) containing 30 lines with integer values (column c1) from 1
> to 30 :
> 
> SELECT percentile_cont(1./3) WITHIN GROUP (ORDER BY c1) FROM x ;
>  percentile_cont
> ------------------
>  10.6666666666667
> (1 ligne)
> SELECT percentile_cont(2./3) WITHIN GROUP (ORDER BY c1) FROM x ;
>  percentile_cont
> ------------------
>  20.3333333333333
> (1 ligne)

Think of the 30 values as points in a graph: The x values run from 0 to
29, the y values are your values. The points are connected with straight
lines. Since your y values just increase by 1 you have a straight line
from (0, 1) to (29, 30)

Then percentile_cont(1./3) is the value y value 1/3 along that line and
percentile_cont(2./3) is the y value 2/3 along that line. So you need to
find the y values corresponding to 29*(1/3) = 9.667 and 29*(2/3) = 19.333.
These are obviously 10.667 and 20.333 respectively.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@xxxxxx         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux