计算两个信号的交叉谱密度示例 -
#! /usr/bin/env python
#coding=utf-8
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19680801)
plt.rcParams['font.sans-serif'] = ['SimHei'] #
plt.rcParams['axes.unicode_minus'] = False
# 原文出自【易百教程】,商业转载请联系作者获得授权,非商业请保留原文链接。
# Fixing random state for reproducibility
fig, (ax1, ax2) = plt.subplots(2, 1)
# make a little extra space between the subplots
fig.subplots_adjust(hspace=0.5)
dt = 0.01
t = np.arange(0, 30, dt)
# Fixing random state for reproducibility
np.random.seed(19680801)
nse1 = np.random.randn(len(t)) # white noise 1
nse2 = np.random.randn(len(t)) # white noise 2
r = np.exp(-t / 0.05)
cnse1 = np.convolve(nse1, r, mode=&