Last active
July 21, 2019 05:02
-
-
Save estysdesu/59089ecddd22a0774ee78d6563f47388 to your computer and use it in GitHub Desktop.
[Python: signal cross correlation (signal/phase comparison)] #cross #correlation #signals #numpy #xcorr #np
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
t = np.linspace(0, 4*np.pi, 100) | |
y1 = np.sin(t) | |
randomizer = lambda x: x + np.random.choice([-1, 1])*np.random.rand() | |
# y2 = np.apply_along_axis(randomizer, 0, y1) # applies once on whole array instead of per element of array | |
vRandomizer = np.vectorize(randomizer) | |
y2 = vRandomizer(y1) | |
corr = np.corrcoef(y1, y2)[0, 1] # choose a value from the left --> right diagonal; either [0, 1] or [1, 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment