UK: adapted mode function from scipy, removed the depency on scipy to only get the mode