boundary/bear — pull request #13 by uwiger (2013-11-04 20:05:12+00:00)
Title: Uw boundary stats subset

When running histograms in high-performance systems, calculating the full histogram can be overly expensive.

If the user wants only a few items - say the mean, min, max, and some percentiles, the calculation can be greatly reduced.

This PR adds the function `bear:get_statistics_subset(Values, Items)`, where `Items` is any subset of the items calculated by `bear:get_statistics/1`. The function tries to be smart about how much to process in order to comply with the request, and can, for the simpler items, reduce calculation cost by almost an order of magnitude.

Example:
```erlang
2> timer:tc(bear, get_statistics, [bear:test_values()]).
{1669,
[{min,1},
{max,9},
{arithmetic_mean,5.5},
{geometric_mean,4.879398280140937},
{harmonic_mean,4.01664748074028},
{median,6},
{variance,4.956},
{standard_deviation,2.226207537495101},
{skewness,-0.3625459389675309},
{kurtosis,-0.8939295881779579},
{percentile,[{50,6},{75,7},{90,8},{95,9},{99,9},{999,9}]},
{histogram,[{3,28},{5,28},{7,42},{9,28},{11,0}]},
{n,126}]}
3> timer:tc(bear, get_statistics_subset, [bear:test_values(), [min,max,{percentile, [75, 90, 95]}]]).
{240,[{min,1},{max,9},{percentile,[{75,7},{90,8},{95,9}]}]}
```