Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Commit

Permalink
Add specification the shape to avoid "-0" which is not the final element
Browse files Browse the repository at this point in the history
  • Loading branch information
teobucci committed Feb 22, 2024
1 parent ca6cb2d commit 004a8e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tefs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ def compute_transfer_entropy(
max_lag = max(max(lag_features), max(lag_target), max(lag_conditioning))

# Filling member1
member1 = np.hstack([X[max_lag - lag : -lag, :] for lag in lag_features])
member1 = np.hstack([X[max_lag - lag : X.shape[0]-lag, :] for lag in lag_features])

# Filling member2
member2 = np.hstack(Y[max_lag:, :])

# Filling member3
member3 = np.hstack([
# Filling the part relative the past of the target
*[Y[max_lag - lag : -lag, :] for lag in lag_target],
*[Y[max_lag - lag : Y.shape[0]-lag, :] for lag in lag_target],
# Filling the part relative the past of the conditioning features
*[Z[max_lag - lag : -lag, :] for lag in lag_conditioning],
*[Z[max_lag - lag : Z.shape[0]-lag, :] for lag in lag_conditioning],
])

return estimate_cmi(member1, member2, member3, k)
Expand Down

0 comments on commit 004a8e3

Please sign in to comment.