Updated DTW compute method to accept distance function as optional argument.