Countig points in boxes of a grid
<p>assume there is a grid with some points in it just like in the plot below. 
<img src="http://i.stack.imgur.com/x8dwF.png" alt="Demo">
My goal is to count the points per box of the grid. And this is my first try.</p>

<pre><code>            for tupel in point_list:
               a=0
               b=0
               for i in self.boxvector:
                  if tupel[0] &lt; i:
                     a=self.boxvector.index(i)-1
                     break

               for i in self.boxvector:
                  if tupel[1] &lt; i:
                     b=self.boxvector.index(i)-1
                     break

               farray[a][b]+=1
</code></pre>

<p>It works, but it is slow. Are there to speed it a little up?</p>

<p>I use a variable named <code>boxvector</code> to define the grid. In this example boxvector is: <code>boxvector = [-1., -.5, 0, .5, 1.]</code>. The grid is always quadratic with maxima at -1 and 1. 
The boxes are represented through <code>farray</code>, which looks like <code>farray = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]</code>. So that there is one value for each box which is incremented every time the algorithm finds a point in the corresponding box. point_list has the form <code>point_list = [(x0,y0),(x1,y1),(x3,y3), ...]</code></p>

<p>Thank you for your help ! </p>
