Finding the most similar numbers across multiple lists in Python
Posted
by
new_sysadmin
on Stack Overflow
See other posts from Stack Overflow
or by new_sysadmin
Published on 2012-09-27T23:22:50Z
Indexed on
2012/09/29
15:38 UTC
Read the original article
Hit count: 177
In Python, I have 3 lists of floating-point numbers (angles), in the range 0-360, and the lists are not the same length. I need to find the triplet (with 1 number from each list) in which the numbers are the closest. (It's highly unlikely that any of the numbers will be identical, since this is real-world data.) I was thinking of using a simple lowest-standard-deviation method to measure agreement, but I'm not sure of a good way to implement this. I could loop through each list, comparing the standard deviation of every possible combination using nested for loops, and have a temporary variable save the indices of the triplet that agrees the best, but I was wondering if anyone had a better or more elegant way to do something like this. Thanks!
© Stack Overflow or respective owner