在python scipy版本1.1中计算信噪比 [英] Calculate Signal to Noise ratio in python scipy version 1.1

查看:1441
本文介绍了在python scipy版本1.1中计算信噪比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上环顾四周,似乎已弃用了 scipy.stats 中的 signaltonoise 比率功能,该功能在1.1版中不可用. scipy软件包内还有其他等效方法,因为我无法在线找到它.

I have looked around online and it seems that the signaltonoise ratio function inside the scipy.stats is deprecated and is not available in version 1.1. Is there any other equivalent method inside scipy package since I have not been able to find it online.

如果不是scipy,那么是否建议使用其他任何库进行此类计算?

And if not scipy then is there any other library recommended for such calculations ?

推荐答案

scipy问题#中所示github上的609 signaltonoise函数

[...] 除了向后兼容以外,没有用.原因是存在Matlab信噪比功能 http://www. mathworks.com/help/signal/ref/snr.html ,这意味着有所不同.这不好,因为scipy克隆了其他信号相关功能的Matlab接口,这种不兼容显然没有抵消作用.

[...] is not useful except for backwards compatibility. The reason is that there's a Matlab signal-to-noise function http://www.mathworks.com/help/signal/ref/snr.html which means something different. This is not good, because scipy clones the Matlab interface of other signal-related functions, and this incompatibility apparently has no offsetting benefit.

如果您确实需要此功能以实现向后兼容,则可以在许可):

If you do need this function for backward compatibility, the short implementation can be found in the history of scipy repository as (reproduced here without the documentation comments, license):

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)

这篇关于在python scipy版本1.1中计算信噪比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆