csd_demo.py
来自「非原创。很好的python例子」· Python 代码 · 共 34 行
PY
34 行
#!/usr/bin/env python"""Compute the cross spectral density of two signals"""from __future__ import divisionfrom pylab import *dt = 0.01t = arange(0, 30, dt)nse1 = randn(len(t)) # white noise 1nse2 = randn(len(t)) # white noise 2r = exp(divide(-t,0.05))cnse1 = convolve(nse1, r, mode=2)*dt # colored noise 1cnse1 = cnse1[:len(t)]cnse2 = convolve(nse2, r, mode=2)*dt # colored noise 2cnse2 = cnse2[:len(t)]# two signals with a coherent part and a random parts1 = 0.01*sin(2*pi*10*t) + cnse1 s2 = 0.01*sin(2*pi*10*t) + cnse2subplot(211)plot(t, s1, 'b-', t, s2, 'g-')xlim(0,5)xlabel('time')ylabel('s1 and s2')subplot(212)cxy, f = csd(s1, s2, 256, 1/dt)show()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?