[SciPy-User] Vector comparison
Éric Depagne
eric at depagne.org
Thu Feb 25 14:16:02 EST 2010
Hi Denis,
> Éric.
> does this one-liner make sense:
> def nearvec( x, vecs ):
> """ the vec nearest x, -> the pair (norm(x - v), v) """
> return min( (np.linalg.norm( x - v[:3] ), v) for v in vecs )
> # py min, not np.min
I'll have a look at it and see how different the results are from my own
method.
>
> Of course change "norm" to xT.A.x if you have an A that weights the
> different components,
> e.g. 1 / sigmaj^2.
Thanks for this, I was looking desperately to find how to include the weights.
>
> Numpy experts can vectorize just about anything
> (a wiki for vectorization examples would be nice, may well exist
> already ?)
Cheers,
Éric.
>
> cheers
> -- denis
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
--
Un clavier azerty en vaut deux
----------------------------------------------------------
Éric Depagne edepagne at lcogt.net
More information about the SciPy-User
mailing list