Distance functions to compare vectors