问题:
如下图所示的问题,给定最小阈值、最大阈值以及一段数据队列,对数据队列中超过阈值部分的极值进行保存,即从队列中得到P1-P6
计算规则
规则类似状态机
首先定义last_type标志位:
{ 上一时刻大于 m a x _ t h : l a s t t y p e = 1 上一时刻在 m a x _ t h 和 m i n _ t h 之间 : l a s t t y p e = 0 上一时刻小于 m i n _ t h : l a s t t y p e = − 1 \left\{ \begin{array}{l} 上一时刻大于max\_th : last_type = 1 \\ 上一时刻在max\_th和min\_th之间 : last_type = 0 \\ 上一时刻小于min\_th : last_type = -1 \\ \end{array} \right. ⎩
⎨
⎧上一时刻大于max_th:lasttype=1上一时刻在max_th和min_th之间:lasttype=0上一时刻小于