In the example below, I am plotting the coherence between time series and itself. The time series do has one frequency.The coherence magnitude was one for all frequencies. I wonder why it is not zero at all frequencies except at the time series frequency. I found that if I include random variable, I get zero coherence at most frequencies except the time series and its surrounding frequencies. Here is my questions:
- Why the coherence is unit for all frequencies however the time series have only single frequency.
- Why I got more realistic (coherence values at the time series frequency, and zero else where) values when I add noise to the time series.
- Why the coherence (with the noise added case) show more unity for more that one frequency. It looks like that the coherence have unit at the time series frequency and the surrounding frequencies.
import matplotlib.pyplot as plt from scipy import signal nt=10000 w1=0.02 xp_pre=np.zeros((nt)) yp_pre=np.zeros((nt)) for t in np.arange(nt): xp_pre[t]=np.cos(2*np.pi*w1*t) yp_pre[t]=np.cos(2*np.pi*w1*t) #xp_pre=xp_pre+np.random.randn(nt)*0.03 #yp_pre=yp_pre+np.random.randn(nt)*0.03 plt.figure();plt.plot(xp_pre);plt.plot(yp_pre);plt.show() #f,coh = signal.coherence(xp_pre,yp_pre,window=signal.get_window('hanning',200),noverlap=100) f,coh = signal.coherence(xp_pre,yp_pre) plt.figure();plt.plot(f,coh,'*') plt.show()