Friday, January 9, 2015

Vectorize your functions in NumPy

One of the features I loved in R, was that I could easily put a matrix into a unitary function.  Picture this, I have a spatial covariance function which relies on the distances.  All I would need to do is write the spatial covariance function, and then just put in the distance matrix.

Maybe it will be easier to see some sample code:

code /code

Feel free to read a little more here, but it's a great way to avoid writing loops, especially when setting covariance matrices.

No comments:

Post a Comment