Table of Contents

Quartile

Symbol Names Definition
Q1 first quartile
lower quartile
25th percentile
splits off the lowest 25% of data from the highest 75%
일사분위수 (하한사분위수)
Q2 second quartile
median
50th percentile
cuts data set in half
(중앙값)
Q3 third quartile
upper quartile
75th percentile
splits off the highest 25% of data from the lowest 75%
삼사분위수 (상한사분위수)

interquartile and outliers

사분범위 = Q3 - Q1
사분범위 = (상한사분위수) - (하한사분위수)

Finding lower and upper quartile

e.g. 1, Head First method

> k <- c(1:8)
> k
[1] 1 2 3 4 5 6 7 8
> quantile(k)
  0%  25%  50%  75% 100% 
1.00 2.75 4.50 6.25 8.00 
> 
{1, 2, 3, 4, 5, 6, 7, 8}

head first

위의 방법으로는
lower quartile: 2.5
upper quartile: 6.5

Ordered Data Set: 6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49

r method

in r

j <- c(1,2,3,4,5)
j <- sort(j)
quantile(j)
> j <- c(1,2,3,4,5)
> j <- sort(j)
> quantile(j)
  0%  25%  50%  75% 100% 
   1    2    3    4    5 
> 

Odd number of elements

j2 <- c(1,2,3,4,5,6)
j2 <- sort(j2)
quantile(j2)
> j2 <- c(1,2,3,4,5,6)
> j2 <- sort(j2)
> quantile(j2)
  0%  25%  50%  75% 100% 
1.00 2.25 3.50 4.75 6.00 
> 
> 

Even number of elements

> j3 <- c(7, 18, 5, 9, 12, 15)
> j3s <- sort(j3)
> j3s
[1]  5  7  9 12 15 18
> quantile(j3s)
   0%   25%   50%   75%  100% 
 5.00  7.50 10.50 14.25 18.00 
> 

median = (9+12)/2
the 1st quartile = 7 + (9-7)*(1/4) = 7 + 0.5 = 7.5
the 3rd quartile = 12 + (12-9)*(3/4) = 12 + 2.25 = 14.25


in r

> duration = faithful$eruptions     # the eruption duration
> quantile(duration)                # apply the quantile function 
    0%    25%    50%    75%   100% 
1.6000 2.1627 4.0000 4.4543 5.1000

quantile, not qurtile