Many big data or scientific programs use boxplots to show distributions of data.   In addition, sometimes saving large arrays for boxplots can be impractical and use extreme amounts of RAM.   It can be useful to save large arrays as arrays with five numbers to save memory.

For example, the   R   programming language implements Tukey's five-number summary as the fivenum function.



Task

Given an array of numbers, compute the five-number summary.



Note
 
While these five numbers can be used to draw a boxplot,   statistical packages will typically need extra data.

Moreover, while there is a consensus about the "box" of the boxplot,   there are variations among statistical packages for the whiskers.




 
program fivenum(X)
rename X^ x
order x 1
dup
project x min, x median, x max, x count
set q1 = x_count / 4
set q1min = floor(q1)
set q1weight = q1 - q1min
set q3 = x_count * 3 / 4
set q3min = floor(q3)
set q3weight = q3 - q3min
swap
dup
select rownumber = q1min + 1 or rownumber = q1min + 2
extend w = q1weight * (rownumber - 1) - (rownumber-1-1) * (1-q1weight)
extend xw = x * w
project xw sum
rename xw_sum x_quarter1
swap
select rownumber = q3min + 1 or rownumber = q3min + 2
extend w = q3weight * (rownumber - 1) - (rownumber-1-1) * (1-q3weight)
extend xw = x * w
project xw sum
rename xw_sum x_quarter3
join cross
join cross
project x_min, x_quarter1, x_median, x_quarter3, x_max
print
end program
 
relation a
insert 3
insert 4
insert 18
insert 12
insert 17
insert 5
insert 6
insert 11
insert 8
run fivenum("a")
 