def mean(X): return np.sum(X, axis=0)/len(X) def std_dev(X, X_bar): return np.sqrt(np.sum((X-X_bar)**2, axis=0)) def cov(X, X_bar, Y, Y_bar): return np.sum((X-X_bar)*(Y-Y_bar), axis=0) np.seterr(divide='ignore', invalid='ignore') np_array = np.array(trace_array) t_bar = mean(np_array) #print(t_bar) o_t = std_dev(np_array, t_bar) #print(o_t) intermediate = np.array(textin_array).transpose() data = np.zeros((16,1000),int) for j in range(0,1000): for k in range(0,16): data[k][j] = intermediate[k][j] output = np.array(textout_array).transpose() data_out = np.zeros((16,1000),int) for j in range(0,1000): for k in range(0,16): data_out[k][j] = output[k][j] print(np_array.shape) print(data.shape) fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=True) #plt.figure() for j in range(0,16): #intermediate = np.array(textin_array).transpose() #print(intermediate) inter = np.array([data[j]]).transpose() d_bar = mean(inter) o_d = std_dev(inter, d_bar) covariance = cov(trace_array, t_bar, inter, d_bar) correlation = covariance/(o_t*o_d) #print(correlation) ax1.plot(correlation) plt.show() for j in range(0,16): inter = np.array([data_out[j]]).transpose() d_bar = mean(inter) o_d = std_dev(inter, d_bar) covariance = cov(trace_array, t_bar, inter, d_bar) correlation = covariance/(o_t*o_d) #print(correlation) ax2.plot(correlation) plt.show()