text 计算PERCENTILE,MEDIAN,PERCENTRANK,Caluculate Deciles和Quartiles

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 计算PERCENTILE,MEDIAN,PERCENTRANK,Caluculate Deciles和Quartiles相关的知识,希望对你有一定的参考价值。

----------------
-- PERCENTILE --
----------------

Percentile is the value at which a certain percentage of values in an array fall below that value, and a certain percentage of values fall above. For example, looking for the 80th percentile means finding a value at which 80% of the values in the array fall below that value, and therefore 20% of the values in the array fall above.

The formula is PERCENTILE(range of values in your array, the percentile you're looking for). The percentile value is expressed as a decimal between 0 and 1 showing the percentage you're looking for: for instance, 0.5 is looking for the 50th percentile, 0.9 is looking for the 90th percentile, etc.

In this example it will calculate the value at which 75% of the values in the array are below that value (and therefore 25% of values are above). The result will be a number such as 2013.12, which means that 75% of values in column Q will fall below 2013.12, and $25% of values in column Q will fall above 2013.12.

=PERCENTILE(Q:Q,0.75)

or

=PERCENTILE.EXC(Q:Q,0.75)

------------
-- MEDIAN --
------------

MEDIAN is bascially a percentile looking for the value of the 50th percentile (half of the values fall above, half of the values fall below). Therefore, 
=MEDIAN(Q2:Q19)

gives the same results as 
=PERCENTILE(Q2:Q19,0.5)

-----------------
-- PERCENTRANK --
-----------------

-- PERCENTRANK shows at what percentile each value in a range falls. This can be helpful when splitting values into deciles or quantiles. 


For example, if you start with these values in your array:
Row Value
1   $39,541,385.16
2   $8,707,780.00
3   $1,110,000.00
4   $737,600.00
5   $614,544.08
6   $558,448.00
7   $509,800.00
8   $414,039.74
9   $405,000.00
10  $394,100.00
11  $388,746.40
12  $379,000.00
13  $365,439.98
14  $328,682.50
15  $306,800.00
16  $260,000.00
17  $249,779.70
18  $240,000.00

-- PERCENTRANK will return percentile values for each value.

=PERCENTRANK(Q:Q,Q3,2) (format is PERCENTRANK(span of array, value you're testing, and number of decimal places you want to include - it'll round the decimal)

Row Value           Percentile
1   $39,541,385.16  1
2   $8,707,780.00   0.9
3   $1,110,000.00   0.8
4   $737,600.00     0.8
5   $614,544.08     0.7
6   $558,448.00     0.7
7   $509,800.00     0.6
8   $414,039.74     0.5
9   $405,000.00     0.5
10  $394,100.00     0.4
11  $388,746.40     0.4
12  $379,000.00     0.3
13  $365,439.98     0.2
14  $328,682.50     0.2
15  $306,800.00     0.1
16  $260,000.00     0.1
17  $249,779.70     0
18  $240,000.00     0

- You can then use a SWITCH formula or a lookup table to assign deciles based on the percentiles that you get from PERCENTRANK

=SWITCH(C2,1,10,0.9,10,0.8,9,0.7,8,0.6,7,0.5,6,0.4,5,0.3,4,0.2,3,0.1,2,0,1)

Row Value           Percentile  Decile
1   $39,541,385.16  1           10th decile
2   $8,707,780.00   0.9         10th decile
3   $1,110,000.00   0.8         9th decile
4   $737,600.00     0.8         9th decile
5   $614,544.08     0.7         8th decile
6   $558,448.00     0.7         8th decile
7   $509,800.00     0.6         7th decile
8   $414,039.74     0.5         6th decile
9   $405,000.00     0.5         6th decile
10  $394,100.00     0.4         5th decile
11  $388,746.40     0.4         5th decile
12  $379,000.00     0.3         4th decile
13  $365,439.98     0.2         3rd decile
14  $328,682.50     0.2         3rd decile
15  $306,800.00     0.1         2nd decile
16  $260,000.00     0.1         2nd decile
17  $249,779.70     0           1st decile
18  $240,000.00     0           1st decile

------------------------------------------
-- PERCENTILES TO QUARTILES AND DECILES --
------------------------------------------

-- how percentiles translate into deciles if you have 100 values (ie the 100 values are broken into ten groups of 10 values)

Number	Percentile	Decile
100	1	10th Decile
99	0.9	10th Decile
98	0.9	10th Decile
97	0.9	10th Decile
96	0.9	10th Decile
95	0.9	10th Decile
94	0.9	10th Decile
93	0.9	10th Decile
92	0.9	10th Decile
91	0.9	10th Decile
90	0.8	9th Decile
89	0.8	9th Decile
88	0.8	9th Decile
87	0.8	9th Decile
86	0.8	9th Decile
85	0.8	9th Decile
84	0.8	9th Decile
83	0.8	9th Decile
82	0.8	9th Decile
81	0.8	9th Decile
80	0.7	8th Decile
79	0.7	8th Decile
78	0.7	8th Decile
77	0.7	8th Decile
76	0.7	8th Decile
75	0.7	8th Decile
74	0.7	8th Decile
73	0.7	8th Decile
72	0.7	8th Decile
71	0.7	8th Decile
70	0.6	7th Decile
69	0.6	7th Decile
68	0.6	7th Decile
67	0.6	7th Decile
66	0.6	7th Decile
65	0.6	7th Decile
64	0.6	7th Decile
63	0.6	7th Decile
62	0.6	7th Decile
61	0.6	7th Decile
60	0.5	6th Decile
59	0.5	6th Decile
58	0.5	6th Decile
57	0.5	6th Decile
56	0.5	6th Decile
55	0.5	6th Decile
54	0.5	6th Decile
53	0.5	6th Decile
52	0.5	6th Decile
51	0.5	6th Decile
50	0.4	5th Decile
49	0.4	5th Decile
48	0.4	5th Decile
47	0.4	5th Decile
46	0.4	5th Decile
45	0.4	5th Decile
44	0.4	5th Decile
43	0.4	5th Decile
42	0.4	5th Decile
41	0.4	5th Decile
40	0.3	4th Decile
39	0.3	4th Decile
38	0.3	4th Decile
37	0.3	4th Decile
36	0.3	4th Decile
35	0.3	4th Decile
34	0.3	4th Decile
33	0.3	4th Decile
32	0.3	4th Decile
31	0.3	4th Decile
30	0.2	3rd Decile
29	0.2	3rd Decile
28	0.2	3rd Decile
27	0.2	3rd Decile
26	0.2	3rd Decile
25	0.2	3rd Decile
24	0.2	3rd Decile
23	0.2	3rd Decile
22	0.2	3rd Decile
21	0.2	3rd Decile
20	0.1	2nd Decile
19	0.1	2nd Decile
18	0.1	2nd Decile
17	0.1	2nd Decile
16	0.1	2nd Decile
15	0.1	2nd Decile
14	0.1	2nd Decile
13	0.1	2nd Decile
12	0.1	2nd Decile
11	0.1	2nd Decile
10	0.0	1st Decile
09	0.0	1st Decile
08	0.0	1st Decile
07	0.0	1st Decile
06	0.0	1st Decile
05	0.0	1st Decile
04	0.0	1st Decile
03	0.0	1st Decile
02	0.0	1st Decile
01	0.0	1st Decile

-- how percentiles translate into quartile if you have 100 values (ie the 100 values are broken into four groups of 25 values)

Number	Percentile	Quartile
100	1	4th Quartile
99	0.9	4th Quartile
98	0.9	4th Quartile
97	0.9	4th Quartile
96	0.9	4th Quartile
95	0.9	4th Quartile
94	0.9	4th Quartile
93	0.9	4th Quartile
92	0.9	4th Quartile
91	0.9	4th Quartile
90	0.8	4th Quartile
89	0.8	4th Quartile
88	0.8	4th Quartile
87	0.8	4th Quartile
86	0.8	4th Quartile
85	0.8	4th Quartile
84	0.8	4th Quartile
83	0.8	4th Quartile
82	0.8	4th Quartile
81	0.8	4th Quartile
80	0.7	4th Quartile
79	0.7	4th Quartile
78	0.7	4th Quartile
77	0.7	4th Quartile
76	0.7	4th Quartile
75	0.7	3rd Quartile
74	0.7	3rd Quartile
73	0.7	3rd Quartile
72	0.7	3rd Quartile
71	0.7	3rd Quartile
70	0.6	3rd Quartile
69	0.6	3rd Quartile
68	0.6	3rd Quartile
67	0.6	3rd Quartile
66	0.6	3rd Quartile
65	0.6	3rd Quartile
64	0.6	3rd Quartile
63	0.6	3rd Quartile
62	0.6	3rd Quartile
61	0.6	3rd Quartile
60	0.5	3rd Quartile
59	0.5	3rd Quartile
58	0.5	3rd Quartile
57	0.5	3rd Quartile
56	0.5	3rd Quartile
55	0.5	3rd Quartile
54	0.5	3rd Quartile
53	0.5	3rd Quartile
52	0.5	3rd Quartile
51	0.5	3rd Quartile
50	0.4	2nd Quartile
49	0.4	2nd Quartile
48	0.4	2nd Quartile
47	0.4	2nd Quartile
46	0.4	2nd Quartile
45	0.4	2nd Quartile
44	0.4	2nd Quartile
43	0.4	2nd Quartile
42	0.4	2nd Quartile
41	0.4	2nd Quartile
40	0.3	2nd Quartile
39	0.3	2nd Quartile
38	0.3	2nd Quartile
37	0.3	2nd Quartile
36	0.3	2nd Quartile
35	0.3	2nd Quartile
34	0.3	2nd Quartile
33	0.3	2nd Quartile
32	0.3	2nd Quartile
31	0.3	2nd Quartile
30	0.2	2nd Quartile
29	0.2	2nd Quartile
28	0.2	2nd Quartile
27	0.2	2nd Quartile
26	0.2	2nd Quartile
25	0.2	1st Quartile
24	0.2	1st Quartile
23	0.2	1st Quartile
22	0.2	1st Quartile
21	0.2	1st Quartile
20	0.1	1st Quartile
19	0.1	1st Quartile
18	0.1	1st Quartile
17	0.1	1st Quartile
16	0.1	1st Quartile
15	0.1	1st Quartile
14	0.1	1st Quartile
13	0.1	1st Quartile
12	0.1	1st Quartile
11	0.1	1st Quartile
10	0	1st Quartile
09	0.0	1st Quartile
08	0.0	1st Quartile
07	0.0	1st Quartile
06	0.0	1st Quartile
05	0.0	1st Quartile
04	0.0	1st Quartile
03	0.0	1st Quartile
02	0.0	1st Quartile
01	0.0	1st Quartile


-- 

-- how percentiles translate into deciles if you have 100 values (ie the 100 values are broken into ten groups of 10 values)

Number	Percentile	Decile
-- 10th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 
100	1	10th Decile
99	0.9	10th Decile
98	0.9	10th Decile
97	0.9	10th Decile
96	0.9	10th Decile
95	0.9	10th Decile
94	0.9	10th Decile
93	0.9	10th Decile
92	0.9	10th Decile
91	0.9	10th Decile
-- 9th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 90th PERCENTILE (<= 90.9) 
90	0.8	9th Decile
89	0.8	9th Decile
88	0.8	9th Decile
87	0.8	9th Decile
86	0.8	9th Decile
85	0.8	9th Decile
84	0.8	9th Decile
83	0.8	9th Decile
82	0.8	9th Decile
81	0.8	9th Decile
-- 8th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW BELOW 80th PERCENTILE (<= 80.9)
80	0.7	8th Decile
79	0.7	8th Decile
78	0.7	8th Decile
77	0.7	8th Decile
76	0.7	8th Decile
75	0.7	8th Decile
74	0.7	8th Decile
73	0.7	8th Decile
72	0.7	8th Decile
71	0.7	8th Decile
-- 7th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 70th PERCENTILE (<= 70.9)
70	0.6	7th Decile
69	0.6	7th Decile
68	0.6	7th Decile
67	0.6	7th Decile
66	0.6	7th Decile
65	0.6	7th Decile
64	0.6	7th Decile
63	0.6	7th Decile
62	0.6	7th Decile
61	0.6	7th Decile
-- 6th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 60th PERCENTILE (<= 60.9)
60	0.5	6th Decile
59	0.5	6th Decile
58	0.5	6th Decile
57	0.5	6th Decile
56	0.5	6th Decile
55	0.5	6th Decile
54	0.5	6th Decile
53	0.5	6th Decile
52	0.5	6th Decile
51	0.5	6th Decile
-- 5th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 50th PERCENTILE (<= 50.9)
50	0.4	5th Decile
49	0.4	5th Decile
48	0.4	5th Decile
47	0.4	5th Decile
46	0.4	5th Decile
45	0.4	5th Decile
44	0.4	5th Decile
43	0.4	5th Decile
42	0.4	5th Decile
41	0.4	5th Decile
-- 4th DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 40th PERCENTILE (<= 40.9)
40	0.3	4th Decile
39	0.3	4th Decile
38	0.3	4th Decile
37	0.3	4th Decile
36	0.3	4th Decile
35	0.3	4th Decile
34	0.3	4th Decile
33	0.3	4th Decile
32	0.3	4th Decile
31	0.3	4th Decile
-- 3rd DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 30th PERCENTILE (<= 30.9)
30	0.2	3rd Decile
29	0.2	3rd Decile
28	0.2	3rd Decile
27	0.2	3rd Decile
26	0.2	3rd Decile
25	0.2	3rd Decile
24	0.2	3rd Decile
23	0.2	3rd Decile
22	0.2	3rd Decile
21	0.2	3rd Decile
-- 2nd DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 20th PERCENTILE (<= 20.9)
20	0.1	2nd Decile
19	0.1	2nd Decile
18	0.1	2nd Decile
17	0.1	2nd Decile
16	0.1	2nd Decile
15	0.1	2nd Decile
14	0.1	2nd Decile
13	0.1	2nd Decile
12	0.1	2nd Decile
11	0.1	2nd Decile
-- 1st DECILE BOUNDARY - CONTAINS EVERYTHING BELOW 10th PERCENTILE (<= 10.9)
10	0.0	1st Decile
09	0.0	1st Decile
08	0.0	1st Decile
07	0.0	1st Decile
06	0.0	1st Decile
05	0.0	1st Decile
04	0.0	1st Decile
03	0.0	1st Decile
02	0.0	1st Decile
01	0.0	1st Decile

-- how percentiles translate into quartile if you have 100 values (ie the 100 values are broken into four groups of 25 values)

Number	Percentile	Quartile
-- 4th QUARTILE BOUNDARY - CONTAINS EVERYTHING BELOW
100	1	4th Quartile
99	0.9	4th Quartile
98	0.9	4th Quartile
97	0.9	4th Quartile
96	0.9	4th Quartile
95	0.9	4th Quartile
94	0.9	4th Quartile
93	0.9	4th Quartile
92	0.9	4th Quartile
91	0.9	4th Quartile
90	0.8	4th Quartile
89	0.8	4th Quartile
88	0.8	4th Quartile
87	0.8	4th Quartile
86	0.8	4th Quartile
85	0.8	4th Quartile
84	0.8	4th Quartile
83	0.8	4th Quartile
82	0.8	4th Quartile
81	0.8	4th Quartile
80	0.7	4th Quartile
79	0.7	4th Quartile
78	0.7	4th Quartile
77	0.7	4th Quartile
76	0.7	4th Quartile
-- 3rd QUARTILE BOUNDARY - CONTAINS EVERYTHING BELOW 75th PERCENTILE (<= 75.9)
75	0.7	3rd Quartile
74	0.7	3rd Quartile
73	0.7	3rd Quartile
72	0.7	3rd Quartile
71	0.7	3rd Quartile
70	0.6	3rd Quartile
69	0.6	3rd Quartile
68	0.6	3rd Quartile
67	0.6	3rd Quartile
66	0.6	3rd Quartile
65	0.6	3rd Quartile
64	0.6	3rd Quartile
63	0.6	3rd Quartile
62	0.6	3rd Quartile
61	0.6	3rd Quartile
60	0.5	3rd Quartile
59	0.5	3rd Quartile
58	0.5	3rd Quartile
57	0.5	3rd Quartile
56	0.5	3rd Quartile
55	0.5	3rd Quartile
54	0.5	3rd Quartile
53	0.5	3rd Quartile
52	0.5	3rd Quartile
51	0.5	3rd Quartile
-- 2nd QUARTILE BOUNDARY - CONTAINS EVERYTHING BELOW 50th PERCENTILE (<= 50.9)
50	0.4	2nd Quartile
49	0.4	2nd Quartile
48	0.4	2nd Quartile
47	0.4	2nd Quartile
46	0.4	2nd Quartile
45	0.4	2nd Quartile
44	0.4	2nd Quartile
43	0.4	2nd Quartile
42	0.4	2nd Quartile
41	0.4	2nd Quartile
40	0.3	2nd Quartile
39	0.3	2nd Quartile
38	0.3	2nd Quartile
37	0.3	2nd Quartile
36	0.3	2nd Quartile
35	0.3	2nd Quartile
34	0.3	2nd Quartile
33	0.3	2nd Quartile
32	0.3	2nd Quartile
31	0.3	2nd Quartile
30	0.2	2nd Quartile
29	0.2	2nd Quartile
28	0.2	2nd Quartile
27	0.2	2nd Quartile
26	0.2	2nd Quartile
-- 1st QUARTILE BOUNDARY - CONTAINS EVERYTHING BELOW 25th PERCENTILE (<= 25.9)
25	0.2	1st Quartile
24	0.2	1st Quartile
23	0.2	1st Quartile
22	0.2	1st Quartile
21	0.2	1st Quartile
20	0.1	1st Quartile
19	0.1	1st Quartile
18	0.1	1st Quartile
17	0.1	1st Quartile
16	0.1	1st Quartile
15	0.1	1st Quartile
14	0.1	1st Quartile
13	0.1	1st Quartile
12	0.1	1st Quartile
11	0.1	1st Quartile
10	0	1st Quartile
09	0.0	1st Quartile
08	0.0	1st Quartile
07	0.0	1st Quartile
06	0.0	1st Quartile
05	0.0	1st Quartile
04	0.0	1st Quartile
03	0.0	1st Quartile
02	0.0	1st Quartile
01	0.0	1st Quartile

以上是关于text 计算PERCENTILE,MEDIAN,PERCENTRANK,Caluculate Deciles和Quartiles的主要内容,如果未能解决你的问题,请参考以下文章

Python计算分位数

hive计算分位数

百分位,百分位数(percentile)

Hive:percentile_approx 原理与实现

如何计算 SQL 中数据的 90th Percentile、SD、Mean

grafana英语参数