[Numpy-discussion] Vectorizing!!!!

Solimyr giannicristian at msn.com
Sat Nov 19 07:23:39 EST 2011

Hi all!!!I'm pretty new here!!
I'm just use my free time to learn something more about python....I just
discovered a new word named 'Vectorizing'....
I'm going to explain my question...I have a matrix (no care about the size)
and I want made some mathematical operations like mean,standard

I post my result so can be usefull for all the newbie to understand the
vectorizing mean:

Mean using a 3x3 window and 2 FOR cicle (a=matrix of interest, b same size
then a but filled with zeros at the start):

        for i in range(1,row-1):
            for j in range(1,col-1):

Very disappointing in term of time..This is with the vectorizing(a=matrix of
interest, c same size then a but filled with zeros at the start):


I have seen that I get a big advantage!!!But my question is:

If I want to calculate the variance in a 3x3 window, can I use the
vectorizing method and 'numpy.var' or I must explain the variance formula?

I don't know if the question is understandable! I have thought something


But doesn't work because I think that numpy.var work over all the matrix and
not only in the 3x3 window!!Is it correct???

Thanks in advance for any answers!!!


View this message in context: http://old.nabble.com/Vectorizing%21%21%21%21-tp32868162p32868162.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

More information about the NumPy-Discussion mailing list