Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pprint
- import numpy as np
- def correlation(x, y, t):
- q = len(x)
- c = 0
- h = []
- soma = []
- for j in xrange(q):
- if x[j] == y[(j + t)%q]:
- c += 1
- h.append([1])
- else:
- h.append([0])
- soma.append([c])
- return t, h, c, "outro tal"
- print soma.append([c])
- def correlation_h(x, y):
- ns1 = len(x)
- ns2 = len(y)
- return [correlation(x, y, i) for i in xrange(-ns2/2, ns1/2 + 1)]
- x = [1, 4, 5, 5, 2, 7, 3, 5, 8, 3, 2, 4, 2, 1, 7, 6, 6, 0, 4, 8, 6, 3, 8, 0, 7, 0]
- y = [[1, 4, 5, 5, 2, 7, 3, 5, 8, 3, 2, 4, 2, 1, 7, 6, 6, 0, 4, 8, 6, 3, 8, 0, 7, 0],
- [25, 4, 18, 10],
- [26, 5, 19, 11],
- [23, 2, 16, 8] ]
- print (correlation_h(x, y[0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement