我试图了解频率估计的过零方法。搜索后,找到了这段代码:
est_freq = round(framerate / np.mean(np.diff(zero_crossings)) / 2)
进一步剖析学习,我写了下面的代码:
import numpy as np
framerate = 1e3
a = [1, 2, 1, 1, -3, -4, 7, 8, 9, 10, -2, 1, -3, 5, 6, 7, -10]
signs = np.sign(a)
diff = np.diff(signs)
indices_of_zero_crossing = np.where(diff)[0]
print(a)
print(signs)
print(diff)
print(indices_of_zero_crossing)
total_points = np.diff(indices_of_zero_crossing)
print(total_points)
average_of_total_points = np.mean(total_points)
print(average_of_total_points)
freq = framerate/average_of_total_points/2
我的问题是, line 发生了什么freq = framerate/average_of_total_points/2
。求过零差的平均值并除以 2 的目的是什么?
有人愿意解释吗?谢谢你。