Re: frequency count or number of occurences of a number in an array

2008-03-13 Thread Bernard
d'oh! On 12 mar, 07:58, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 12, 10:29 pm, Bernard <[EMAIL PROTECTED]> wrote: > > > > > Hey Larry, > > > that one is fairly easy: > > > >>> from array import array > > >>> array('i', [1, 2, 3, 4, 5, 1, 2]) > > >>> def count(x, arr): > > >         cpt = 0

Re: frequency count or number of occurences of a number in an array

2008-03-12 Thread Larry
Thanks to all those who replied to this post. I'm gonna try your suggestions. They are a great help. -- http://mail.python.org/mailman/listinfo/python-list

Re: frequency count or number of occurences of a number in an array

2008-03-12 Thread John Machin
On Mar 12, 10:29 pm, Bernard <[EMAIL PROTECTED]> wrote: > Hey Larry, > > that one is fairly easy: > > >>> from array import array > >>> array('i', [1, 2, 3, 4, 5, 1, 2]) > >>> def count(x, arr): > > cpt = 0 # declare a counter variable > for el in arr: # for each element in the arra

Re: frequency count or number of occurences of a number in an array

2008-03-12 Thread Bernard
Hey Larry, that one is fairly easy: >>> from array import array >>> array('i', [1, 2, 3, 4, 5, 1, 2]) >>> def count(x, arr): cpt = 0 # declare a counter variable for el in arr: # for each element in the array if el == x: # when it is equal to the 'x' value

Re: frequency count or number of occurences of a number in an array

2008-03-12 Thread Paul Hankin
On Mar 12, 10:26 am, Larry <[EMAIL PROTECTED]> wrote: > I'm new to Python. I have a file (an image file actually) that I need > to read pixel by pixel. It's an 8-bit integer type. I need to get the > statistics like mean, standard deviation, etc., which I know a little > bit already from reading nu

frequency count or number of occurences of a number in an array

2008-03-12 Thread Larry
Dear all, I'm new to Python. I have a file (an image file actually) that I need to read pixel by pixel. It's an 8-bit integer type. I need to get the statistics like mean, standard deviation, etc., which I know a little bit already from reading numpy module. What I want to know is how to get the n