confidence_interval
Calculate confidence intervals for a numeric column using t-distribution or bootstrap median, with customizable confidence level.
Instructions
confidence_interval —— 统计推断组 · 置信区间(工具 10,核心实现)。
docstring = agent 使用说明书,与 statlab_mcp/docs/design/03_inference_batch1.md 同步维护。
参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) column (str): 分析列(须为数值列) confidence (float, 0.95): 置信水平 ∈ (0,1) method (str, "mean_t"): mean_t / bootstrap_median mean_t: mean ± t_{1-α/2, n-1} * sd/√n(sd 用 ddof=1,与 describe 同口径) bootstrap_median: 局部 default_rng(42) 重采样 1000 次取中位数,2.5%/97.5% 分位数(percentile 法)——每次调用独立可复现(不依赖全局 rng 状态)
边界: n<3 / confidence 越界 / method 非法 / 非数值或缺列 —— 中文报错; 常数列(sd=0)区间退化为点并注明。
示例: confidence_interval("samples/clean.csv", column="income") confidence_interval("samples/clean.csv", column="income", confidence=0.90, method="bootstrap_median") 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 |
|---|---|---|---|
| column | No | ||
| method | No | mean_t | |
| file_path | No | ||
| confidence | No | ||
| inline_data | No |