Attaching a patch.

I went for a non-adaptive approach: you have to specify the formula (a "segmenter" implementation: I don't much like the name) by which to bucket your values ahead of time, as well as the number of buckets. I wrote one implementation of this formula (using a TreeMap), and linear and exponential versions make sense too.

This may be more convoluted than necessary: I support generic buckets, not just numbers.

I looked around a bit on whether I should have borrowed other Apache-licensed code. http://code.google.com/p/hist4j/ has an adaptive approach. Apache commons math has summary statistics code.

Attaching a patch.

I went for a non-adaptive approach: you have to specify the formula (a "segmenter" implementation: I don't much like the name) by which to bucket your values ahead of time, as well as the number of buckets. I wrote one implementation of this formula (using a TreeMap), and linear and exponential versions make sense too.

This may be more convoluted than necessary: I support generic buckets, not just numbers.

I looked around a bit on whether I should have borrowed other Apache-licensed code. http://code.google.com/p/hist4j/ has an adaptive approach. Apache commons math has summary statistics code.