[Chicago] Closest Index

Brian Ray brianhray at gmail.com
Sat Jan 5 00:01:31 CET 2013


Maybe you can use numpy abs for each in b using map after sort? Just take A
- (value in b) run abs an then .argmin(). That should return the index that
is closest in A.


On Fri, Jan 4, 2013 at 4:11 PM, Oren Livne <livne at uchicago.edu> wrote:

> Dear All,
>
> I have an sorted array A of size 3.4M of positive integers and an array B
> of size 300,000 of positive integers. I would like to output for each x in
> B the value in A that is closest to it. This is easy to do for a single
> element, but I need an efficient implementation for the entire of B. Any
> suggestions?
>
> Thanks,
> Oren
>
> --
> A person is just about as big as the things that make him angry.
>
> ______________________________**_________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/**mailman/listinfo/chicago<http://mail.python.org/mailman/listinfo/chicago>
>



-- 
Brian Ray
@brianray
(773) 669-7717
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20130104/65ed02da/attachment.html>


More information about the Chicago mailing list