Task
Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the interquartile mean.
One possible algorithm
- Discard the lowest and highest quarters of the data points.
- Calculate the average (sum divided by count) of the remaining data points.
Note: If the dataset size is not evenly split-able in four, you will have to weigh the datapoints that are shared by sub-sets. See Example evaluation 2 below.
Example evaluation 1
Given {1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38}
- Data count is 12, so we remove lowest and highest 3 datapoints:
{1, 3, 4,5, 6, 6, 7, 7, 8,8, 9, 38} - Average of the remaining 6 datapoints:
(5 + 6 + 6 + 7 + 7 + 8) / 6 = 6.5
Example evaluation 2
Given {1, 3, 5, 7, 9, 11, 13, 15, 17}
- Count is 9, so each quarter has 2¼ datapoints:
{1, 2, (0.25×5),(0.75×5), 7, 9, 11, (0.75×13),(0.25×13), 15, 17} - Average of the remaining 4.5 datapoints:
(0.75×5 + 7 + 9 + 11 + 0.75×13) / 4.5 = 9