window_MI = {} i = self._tau_max while i <= lx - self._window : curr_coef_lag = [] for k in lag_array : if k <= 0 : # For negative tau curr_x = x[i : i + self._window].values curr_y = y[i + k : i + k + self._window].values else : # For positive tau curr_x = x[i - k : i - k + self._window].values curr_y = y[i : i + self._window].values 'Compute MI for current segments' curr_MI = mi.compute([pd.DataFrame(curr_x), pd.DataFrame(curr_y)]) curr_coef_lag.append(curr_MI['MI']) window_MI.update({float(i) : curr_coef_lag}) ' go to the next window ' i += self._win_inc window_MI['Lag'] = [float(x) for x in lag_array] self.res = window_MI self.plot() return window_MI
window_MI = {} i = self._tau_max while i <= lx - self._window: curr_coef_lag = [] fixed_x = pd.DataFrame(x[i:i + self._window].values) fixed_y = pd.DataFrame(y[i:i + self._window].values) # For negative tau for k in lag_array[lag_array <= 0]: curr_y = y[i + k:i + k + self._window].values 'Compute MI for current segments' curr_MI = mi.compute(fixed_x, pd.DataFrame(curr_y)) curr_coef_lag.append(curr_MI['MI']) # For positive tau for k in lag_array[lag_array > 0]: curr_x = x[i - k:i - k + self._window].values 'Compute MI for current segments' curr_MI = mi.compute(pd.DataFrame(curr_x), fixed_y) curr_coef_lag.append(curr_MI['MI']) window_MI.update({float(i): curr_coef_lag}) ' go to the next window '
i = self._tau_max while i <= lx - self._window: curr_coef_lag = [] for k in lag_array: if k <= 0: # For negative tau curr_x = x[i:i + self._window].values curr_y = y[i + k:i + k + self._window].values else: # For positive tau curr_x = x[i - k:i - k + self._window].values curr_y = y[i:i + self._window].values 'Compute MI for current segments' curr_MI = mi.compute( [pd.DataFrame(curr_x), pd.DataFrame(curr_y)]) curr_coef_lag.append(curr_MI['MI']) window_MI.update({float(i): curr_coef_lag}) ' go to the next window ' i += self._win_inc window_MI['Lag'] = [float(x) for x in lag_array] self.res = window_MI self.plot()
window_MI = {} i = self._tau_max while i <= lx - self._window: curr_coef_lag = [] fixed_x = pd.DataFrame(x[i: i + self._window].values) fixed_y = pd.DataFrame(y[i: i + self._window].values) # For negative tau for k in lag_array[lag_array <= 0]: curr_y = y[i + k: i + k + self._window].values 'Compute MI for current segments' curr_MI = mi.compute(fixed_x, pd.DataFrame(curr_y)) curr_coef_lag.append(curr_MI['MI']) # For positive tau for k in lag_array[lag_array > 0]: curr_x = x[i - k: i - k + self._window].values 'Compute MI for current segments' curr_MI = mi.compute(pd.DataFrame(curr_x), fixed_y) curr_coef_lag.append(curr_MI['MI']) window_MI.update({float(i) : curr_coef_lag}) ' go to the next window '