trend_analysis
Detect and quantify trends in time-series data with Mann-Kendall and Theil-Sen methods. Returns trend direction, strength, and significance (tau, p, slope) from CSV, JSON, Excel, or inline data.
Instructions
trend_analysis —— 时序组 · 趋势分析(工具 19,简化实现)。
docstring = agent 使用说明书,与 statlab_mcp/docs/design/06_timeseries.md 同步维护。
参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) date_col / value_col (str): 日期列与数值列 method (str, "mann_kendall"): mann_kendall / theil_sen
口径: Mann-Kendall:scipy.stats.kendalltau(y, 时间序号) 的 tau 与 p(MK 检验的 tau 统计量 + 正态近似双侧 p,scipy 官方实现,输出注明该口径); Theil-Sen 斜率:点对斜率中位数(n<=2000 全枚举;n>2000 固定 seed 抽样 50000 对并注明);两种方法都输出 tau/p/slope,method 决定 slope 的计算主口径 (theil_sen 时 slope 为点对中位数;mann_kendall 时 slope 同样用 Theil-Sen 斜率, tau 为主统计量)。 含季节成分时输出"趋势结论需谨慎"警示(设计文档:不校正)。
示例: trend_analysis("samples/timeseries.csv", date_col="date", value_col="value") inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | mann_kendall | |
| date_col | No | ||
| file_path | No | ||
| value_col | No | ||
| inline_data | No |