scipy峰检测中的“宽度”是什么意思

问题描述

这是我正在尝试的示例:

import numpy
from scipy.signal import find_peaks
test = numpy.random.uniform(0.8,1.0,20)
plt.plot(test)

enter image description here

然后,我尝试了 find_peaks(test,width=3),部分输出看起来像

array([ 6,12])
'left_bases': array([0,8]),'right_bases': array([ 8,18]),'widths': array([4.27554389,4.16236512])

我想知道这些输出是什么意思,输出中的 widths 与我输入的 width 有何关联? (如果我将 width 更改为 1 或 0,则会检测到更多峰值。)我看过文档 here,但仍然无法理解它们的含义。

感谢您的帮助:)

解决方法

据我所知,the width parameter 表示峰值需要持续超过例如一个样品被注册为一个峰。

这对您生成的数据没有多大意义,在您给定的采样率下,它本质上是噪声(实际上),但是如果您要将 20 个样本数组重新采样为 2000 个样本,那么您需要更大的 width 才能正确捕获峰值。