Skip to content

Instantly share code, notes, and snippets.

@clungzta
Last active August 29, 2015 14:25
Show Gist options
  • Save clungzta/98f453f6aafd2b69643b to your computer and use it in GitHub Desktop.
Save clungzta/98f453f6aafd2b69643b to your computer and use it in GitHub Desktop.
#Returns the normalised correlation (a number that represents the similarity) between lists of y coordinates
#Note: ENSURE that and both lists are of identical length, delta x remains constant and x coordinate is common to both lists
import numpy as np
a = [0, 1, 0.5]
b = [100, 1, 0.5]
output = np.correlate((a - np.mean(a)) / (np.std(a) * len(a)), (b - np.mean(b)) / np.std(b)) #Normalised correlation
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment