'Maximum Correlation with SciPy cross correlation
I'm trying to do a cross-correlation with SciPy and getting the lags for my data is working fine. I'm working in a while loop to calculate this for a bunch of data sets.
The problem I'm having is with the maximum correlation value: If I use np.argmax(correlation) or np.max(correlation), I get numbers that are not even included in the list correlation itself (e.g. 9876, 86).
Does anyone know why that is and what I need to do instead?
import numpy as np
import pandas as pd
import scipy.stats as stats
correlation = signal.correlate(eventindex, stress, mode="full")
lags = signal.correlation_lags(len(eventindex), len(stress), mode="full")
lag = lags[np.argmax(correlation)]
mcorr = np.argmax(correlation)
max_corr.append(mcorr)
lag_stressrate.append(lag)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
