Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diffs returns two diffrences - differences between consecutive time periods, and differences with the first time period (t=0) #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tcorex/covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ def calculate_nll_score(data, covs):


def diffs(matrices, norm='fro'):
""" Computes the norms of differences of neighboring matrices.
""" Computes the norms of differences of neighboring matrices, and differences w.r.t matrix at time t=0
:param matrices: list of matrices
:param ord: variable that will be passed to np.linalg.norm
"""
nt = len(matrices)

ret = []
for t in range(nt - 1):
ret.append(np.linalg.norm(matrices[t] - matrices[t+1], ord=norm))
return ret
ret_zero = []

for t in range(0, nt - 1):
ret.append(np.linalg.norm(matrices[t+1] - matrices[t], ord=norm))
ret_zero.append(np.linalg.norm(matrices[t+1] - matrices[0], ord=norm))

return ret, ret_zero


def reorder(mat, clusters):
Expand Down