sah*_*ahu 4 python signal-processing numpy image-processing scipy
我在网上看了一下,似乎不推荐使用scipy.stats中的signaltonoise比率函数,并且在1.1版本中不可用.因为我无法在网上找到它,所以在scipy包中是否还有其他等效方法.
如果不是scipy那么是否有其他库推荐用于此类计算?
如github上的scipy问题#609所示,该signaltonoise函数
除了向后兼容性之外,[...]没用.原因是有一个Matlab信噪比函数http://www.mathworks.com/help/signal/ref/snr.html这意味着不同的东西.这并不好,因为scipy克隆了其他信号相关功能的Matlab接口,而这种不兼容性显然没有抵消的好处.
如果您确实需要此功能以实现向后兼容,则可以在scipy存储库的历史记录中找到简短的实现(在此处没有文档注释,许可证):
def signaltonoise(a, axis=0, ddof=0):
a = np.asanyarray(a)
m = a.mean(axis)
sd = a.std(axis=axis, ddof=ddof)
return np.where(sd == 0, 0, m/sd)
Run Code Online (Sandbox Code Playgroud)