test_pink_noise.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:pactools 作者: pactools 项目源码 文件源码
def test_pink_noise_slope():
    n_points = 10000
    fs = 500.0
    try:
        from sklearn.linear_model import LinearRegression
    except ImportError:
        return True

    # test the slope
    for slope in [1, 1.5, 2]:
        noise = pink_noise(n_points, slope=slope)
        spec = Spectrum(fs=fs)
        psd = spec.periodogram(noise).T

        freq = np.linspace(0, fs / 2., psd.size)[:, None]

        # linear regression fit in the log domain
        reg = LinearRegression()
        reg.fit(np.log10(freq[1:]), np.log10(psd[1:]))
        assert_almost_equal(reg.coef_[0][0], -slope, decimal=1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号