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,
Jump to content
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-xList) + abs(yList-yList)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-xList + yList-yList 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.