观察基线
原能力
记录常态范围、已知周期和比较窗口,给后续异常检查保留同口径参照。(细化版 p.4–5)
首选项目
statsmodels(BSD-3-Clause)。 statsmodels
接入说明
首选 STL 分解已对齐的观察序列,窗口对齐由 DuckDB 补充。
匹配范围
窗口分组及 STL 趋势/季节项建立参考序列。
源码
statsmodels · cdef class STL
statsmodels/tsa/stl/_stl.pyx · 106–119 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
cdef class STL(object):
"""
STL(endog, period=None, seasonal=7, trend=None, low_pass=None, seasonal_deg=1, trend_deg=1, low_pass_deg=1, robust=False, seasonal_jump=1, trend_jump=1, low_pass_jump=1)
Season-Trend decomposition using LOESS.
Parameters
----------
endog : array_like
Data to be decomposed. Must be 1-d or an (n, 1) column, such as a
one-column DataFrame.
period : int, optional
Periodicity of the sequence. If None and endog is a pandas Series or
DataFrame, attempts to determine from endog. If endog is a ndarray,
DuckDB · void WindowAggregateExecutor::EvaluateInternal(
src/function/window/window_aggregate_function.cpp · 254–265 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
void WindowAggregateExecutor::EvaluateInternal(ExecutionContext &context, DataChunk &eval_chunk, DataChunk &bounds,
Vector &result, idx_t row_idx, OperatorSinkInput &sink) const {
auto &gastate = sink.global_state.Cast<WindowAggregateExecutorGlobalState>();
auto &lastate = sink.local_state.Cast<WindowAggregateExecutorLocalState>();
auto &gsink = gastate.gsink;
D_ASSERT(aggregator);
OperatorSinkInput asink {*gsink, *lastate.aggregator_state, sink.interrupt_state};
aggregator->Evaluate(context, bounds, result, bounds.size(), row_idx, asink);
}
} // namespace duckdb
实现与验收要点
指定采样单位、参考时期、排除异常和合理窗口。