def sts_matrix_generator(ind, slope_matrix):
"""Work-horse function. Computes the short time-series (STS) distance for
an index, ind of the slope matrix.
Parameters
----------
ind: int
The index of the slope matrix that is being computed.
slope_matrix: np.matrix
The slope matrix.
Returns
-------
(ind, dists): ind is the index and dists is a np.matrix containing the
STS distances
"""
mx = slope_matrix[ind, :]
mv = slope_matrix[ind:, :]
mx_rep = np.vstack((mx,)*mv.shape[0])
diff = mx_rep - mv
diff = np.square(diff)
sts_squared = diff.sum(axis=1)
dists = np.sqrt(sts_squared)
return (ind, dists)
# DBSCAN from scikit learn
评论列表
文章目录