numpy: frequencies
Filip Wasilewski
filipwasilewski at gmail.com
Sat Nov 18 09:31:40 EST 2006
robert wrote:
> I have an integer array with values limited to range(a,b) like:
>
> ia=array([1,2,3,3,3,4,...2,0,1])
>
> and want to speedly count the frequencies of the integers into get a density matrix.
> Is this possible without looping?
See numpy.bincount (for integers >= 0) if you mean 'without writing
looping code in Python' or please specify your question.
> Question 2: is it possible to compute a "moving maximum" without python looping
>
> ia=array([4,2,1,5,3,2,2,0,1,1])
> -> mvmax(ia,3) ->
> [4,4,4,5,5,5,3,2,2,1])
I haven't seen a ready solution but this can be easily converted into
Pyrex/C looping.
cheers,
fw
More information about the Python-list
mailing list