INNER CODE UNIT · Python
discords
target/matrixprofile-ts · matrixprofile/discords.py:13
def discords(mp,ex_zone,k=3):
"""
Computes the top k discords from a matrix profile
Parameters
----------
mp: matrix profile numpy array
k: the number of discords to discover
ex_zone: the number of samples to exclude and set to Inf on either side of a found discord
Returns a list of indexes represent the discord starting locations. MaxInt indicates there
were no more discords that could be found due to too many exclusions or profile being too
small. Discord start indices are sorted by highest matrix profile value.
"""
k = len(mp) if k > len(mp) else k
mp_current = np.copy(mp)
d = np.zeros(k, dtype='int')