两个时间序列(时序信号)的水平位移(重叠程度),对两者互信息值的影响
1、x和y完全重叠;
MIStimulation(xspike=100, yspike=100)
2、x和y相差1
MIStimulation(xspike=100, yspike=101)
3、x和y相差10
MIStimulation(xspike=100, yspike=110)
3、x和y相差100
MIStimulation(xspike=100, yspike=200)
结论:信号在时序上的重叠程度会影响MI。为什么会出现这种结果呢,因为计算MI时,会计算两者的联合概率分布,当两个信号不重叠的时候,联合概率分布基本上处处为0,所以MI也基本上为0;
def MIStimulation(xspike=500, yspike=500):
x = np.zeros(1000)
y = np.zeros(1000)
ratio = 0.94
x[xspike] = 2
for i in range(xspike+1,xspike+200):
x[i] = x[i-1] * ratio
# print(x[i])
y[yspike] = 2
for i in range(yspike+1,yspike+200):
y[i] = y[i-1] * ratio
# print(y[i])
mi = calMI(x, y)
fig, ax = plt.subplots()
ax.plot(x)
ax.plot(y)
ax.set_title('xspike is {}, yspike is {}. MI between x and y is {:.2f}'.format(xspike, yspike, mi))
fig.show()
print()
nd y is {:.2f}'.format(xspike, yspike, mi))
fig.show()
print()