I've been trying to craft a Manhattan distance function in Python.
However, it seems quite straight forward but I am having trouble.
Can anyone help me out with Manhattan distance metric written in Python?
Thanks in advance,
Smitty
Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.
Create Account How it Works#This operation returns the Manhattan distance. # def getManhattan(xList,yList): return float(xList[0]-xList[1]) + abs(yList[0]-yList[1])As a note here, you may need to swap the 1 and 0 around, depending on how you are storing points. I would expect xList[1]-xList[0] + yList[1]-yList[0] to be closer to what you need, but I'm not sure how exactly you are storing points, so I can't be 100% certain.
0 members, 0 guests, 0 anonymous users
Community Forum Software by IP.Board
Licensed to: Geeks to Go, Inc.