Skip to content

Instantly share code, notes, and snippets.

@suhaskv
Created January 1, 2021 14:11
Show Gist options
  • Save suhaskv/898b0ab14e8a459b5abd4d2a9b08d188 to your computer and use it in GitHub Desktop.
Save suhaskv/898b0ab14e8a459b5abd4d2a9b08d188 to your computer and use it in GitHub Desktop.
VSB Power Line Blog - Katz FD
def katz_fd(x):
x = np.array(x)
# Get the difference between consecutive elements of x
dists = np.abs(np.ediff1d(x))
# Get the sum of all the differences
l1 = dists.sum()
# Divide each value of dists (diff. b/w consec. elements) with its mean value and take the log10
ln = np.log10(np.divide(l1, dists.mean()))
# Get the difference between the first value of the sequence with all the elements of the sequence
aux_d = x - x[0]
# Get the absolute maximum difference of the 1st value of seq. with all elements of seq.
d = np.max(np.abs(aux_d[1:]))
return np.divide(ln, np.add(ln, np.log10(np.divide(d, l1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment