Categorizing positive and negative integers inside of an array
<p>I recently asked a <a href="http://stackoverflow.com/questions/13074769/determining-an-arrays-value-depending-on-another-array#comment17763603_13074769">similar question</a> to this one, however I realized now I've made a mistake in it.</p>

<p>I have two arrays, array1 contains numbers which I will later plot, array2 will contain these numbers according to a grouping which the fit in. This grouping is determined on a number, interval which is calculated like so:</p>

<pre><code>interval = ((maxValueFromArray1 - minValueFromArray1) / numRows)
numRows = Math.cbrt(3 * n)
n = Size of array1
</code></pre>

<p>The numbers in array1 are both positive and negative, what I need to do is like so:</p>

<pre><code>...
interval *-2 -0.1 &lt; numFromArray1 &gt; interval *-3
interval *-1 -0.1 &lt; numFromArray1 &gt; interval *-2
0 - 0.1           &lt; numFromArray1 &gt; interval *-1
interval          &lt; numFromArray1 &gt; 0
interval *2       &lt; numFromArray1 &gt; interval + 0.1
interval *3       &lt; numFromArray1 &gt; interval *2 + 0.1
interval *4       &lt; numFromArray1 &gt; interval *3 + 0.1
...
</code></pre>

<p>This way the middle of array2 is equal to numbers from array1 where they're smaller than the interval yet larger than zero. My problem however is that I have no clue on how to achieve this, does anyone know how to help me with this or am I just overcomplicating this problem?</p>

<p>An example of this would be:</p>

<p>interval = 2, numbers inside array1 = 0, -1, -3, 5, 6, 7, 9. It would output something like so:</p>

<pre><code>-10 | -9 ||
-8  | -7 ||
-6  | -5 ||
-4  | -3 || 1
-2  | -1 || 1
0   | 2  || 1
3   | 4  ||
5   | 6  || 2
7   | 8  || 1
9   | 10 || 2
</code></pre>

<p>I already have the minimum value and maximum value figured out, I just need to find a way of creating a way of categorizing these numbers inside of an array so that when the time comes to output them it's just a matter of having a for loop to output a symbol the amount of times it's found each time in an element inside of array2.</p>
