Java: Generating distribution of values in an ArrayList

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2011-03-04T15:08:06Z Indexed on 2011/03/04 15:24 UTC
Read the original article Hit count: 222

Filed under:
|

Hi all,

I have a sorted ArrayList of values. I would like to get the distribution of the values. For example:

  • Say I have 500 values, ranging from 1-100.
  • I want to break them up into groups, say 10 groups: values 1-10, 11-20, 21-30, etc...
  • I want the counts of each of the 500 values that fall into each category. For example, 5 of the 500 are valued at 1-10, 20 between 11-20, etc...
  • However, I do not know the ranges of values in my ArrayList, it could be ranging from 1-30 or 1-200, but I want to break it up into, for example, 10 groups.

Does anyone know how to do this?

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist