Last active
March 19, 2021 18:32
-
-
Save vncsna/88977314ba9ce5daafd9226dd37b3a7f to your computer and use it in GitHub Desktop.
main part of sort and conquer algorithm proposed by Ghosh et al
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
def sort_and_conquer(x): | |
'''Sort and conquer algorithm proposed by Ghosh et al. | |
Parameters: | |
x: numpy.array | |
A 1d time series. | |
''' | |
n = x.size | |
sortd = np.argsort(x)[::-1] | |
graph = sparse.lil_matrix((n, n)) | |
for i in np.arange(n): | |
current = sortd[i] | |
connected = graph.rows[current] | |
left = -1 | |
right = n | |
for j in connected: | |
if j < current: | |
left = max(left, j) | |
else: | |
right = min(right, j) | |
wvisibility(x, left, right, current, graph) | |
return sparse.csr_matrix(graph) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment