Re: How do work tercile, percentile & funcion percentile_cont() ?
Вложения
В списке pgsql-general по дате отправления:
| От | Peter J. Holzer |
|---|---|
| Тема | Re: How do work tercile, percentile & funcion percentile_cont() ? |
| Дата | |
| Msg-id | 20200422230322.GB4048@hjp.at обсуждение |
| Ответ на | How do work tercile, percentile & funcion percentile_cont() ? (PALAYRET Jacques <jacques.palayret@meteo.fr>) |
| Список | pgsql-general |
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@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера