statistical-analysis by anthropics/knowledge-work-plugins
npx skills add https://github.com/anthropics/knowledge-work-plugins --skill statistical-analysis描述性统计、趋势分析、异常值检测、假设检验,以及关于何时对统计结论保持谨慎的指导。
根据数据选择合适的中心度量:
| 情况 | 使用 | 原因 |
|---|---|---|
| 对称分布,无异常值 | 均值 | 最有效的估计量 |
| 偏态分布 | 中位数 | 对异常值稳健 |
| 分类或顺序数据 | 众数 | 非数值数据的唯一选择 |
| 高度偏态且存在异常值(例如,每用户收入) | 中位数 + 均值 | 同时报告;差距显示偏斜程度 |
对于业务指标,始终同时报告均值和中位数。 如果两者差异显著,则数据存在偏斜,仅使用均值会产生误导。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
报告关键百分位数,以提供比单独均值更丰富的信息:
p1: 底部 1%(下限 / 最小典型值)
p5: 正常范围的低端
p25: 第一四分位数
p50: 中位数(典型用户)
p75: 第三四分位数
p90: 前 10% / 高价值用户
p95: 正常范围的高端
p99: 前 1% / 极端用户
示例叙述:"会话时长的中位数是 4.2 分钟,但前 10% 的用户每次会话花费超过 22 分钟,这将均值拉高到了 7.8 分钟。"
描述你分析的每个数值分布的特征:
移动平均以平滑噪声:
# 7日移动平均(适用于具有周季节性的日度数据)
df['ma_7d'] = df['metric'].rolling(window=7, min_periods=1).mean()
# 28日移动平均(平滑周度和月度模式)
df['ma_28d'] = df['metric'].rolling(window=28, min_periods=1).mean()
周期对比 :
增长率 :
简单增长率:(当期 - 前期) / 前期
复合年增长率:(期末 / 期初) ^ (1 / 年数) - 1
对数增长率:ln(当期 / 前期) -- 适用于波动较大的序列
检查周期性模式:
对于业务分析师(非数据科学家),使用直接的方法:
始终传达不确定性。提供一个范围,而不是点估计:
何时需要升级到数据科学家 :非线性趋势、多重季节性、外部因素(营销支出、节假日),或者当预测准确性对资源分配至关重要时。
Z 分数法(适用于正态分布数据):
z_scores = (df['value'] - df['value'].mean()) / df['value'].std()
outliers = df[abs(z_scores) > 3] # 超过 3 个标准差
四分位距法(对非正态分布稳健):
Q1 = df['value'].quantile(0.25)
Q3 = df['value'].quantile(0.75)
IQR = Q3 - Q1
lower_bound = Q1 - 1.5 * IQR
upper_bound = Q3 + 1.5 * IQR
outliers = df[(df['value'] < lower_bound) | (df['value'] > upper_bound)]
百分位数法(最简单):
outliers = df[(df['value'] < df['value'].quantile(0.01)) |
(df['value'] > df['value'].quantile(0.99))]
不要自动删除异常值。而是:
报告你的操作:"我们排除了 47 条交易金额 >5 万美元的记录(0.3%),这些代表单独分析的企业批量订单。"
用于检测时间序列中的异常值:
当你需要确定观察到的差异是真实的还是可能由随机机会造成时,使用假设检验。常见场景:
| 场景 | 检验 | 何时使用 |
|---|---|---|
| 比较两组均值 | t 检验(独立) | 正态数据,两组 |
| 比较两组比例 | 比例 z 检验 | 转化率,二元结果 |
| 比较配对测量值 | 配对 t 检验 | 同一实体的前后对比 |
| 比较 3 组以上均值 | 方差分析 | 多个细分群体或变体 |
| 非正态数据,两组 | Mann-Whitney U 检验 | 偏态指标,顺序数据 |
| 类别之间的关联 | 卡方检验 | 两个分类变量 |
统计显著性 意味着差异不太可能由偶然造成。
实际显著性 意味着差异大到足以影响业务决策。
差异可能在统计上显著但在实际上无意义(常见于大样本)。始终报告:
当你发现相关性时,请明确考虑:
你可以说:"使用功能 X 的用户留存率高出 30%"
没有更多证据你不能说:"功能 X 导致留存率提高 30%"
当你检验许多假设时,有些会偶然"显著":
聚合数据中的趋势在数据细分后可能反转:
你只能分析那些"幸存"到你的数据集中的实体:
总体趋势可能不适用于个体:
警惕虚假的精确性:
每周安装量
311
代码仓库
GitHub 星标数
8.8K
首次出现
2026 年 1 月 31 日
安全审计
安装于
opencode252
codex241
gemini-cli235
claude-code227
github-copilot224
kimi-cli207
Descriptive statistics, trend analysis, outlier detection, hypothesis testing, and guidance on when to be cautious about statistical claims.
Choose the right measure of center based on the data:
| Situation | Use | Why |
|---|---|---|
| Symmetric distribution, no outliers | Mean | Most efficient estimator |
| Skewed distribution | Median | Robust to outliers |
| Categorical or ordinal data | Mode | Only option for non-numeric |
| Highly skewed with outliers (e.g., revenue per user) | Median + mean | Report both; the gap shows skew |
Always report mean and median together for business metrics. If they diverge significantly, the data is skewed and the mean alone is misleading.
Report key percentiles to tell a richer story than mean alone:
p1: Bottom 1% (floor / minimum typical value)
p5: Low end of normal range
p25: First quartile
p50: Median (typical user)
p75: Third quartile
p90: Top 10% / power users
p95: High end of normal range
p99: Top 1% / extreme users
Example narrative : "The median session duration is 4.2 minutes, but the top 10% of users spend over 22 minutes per session, pulling the mean up to 7.8 minutes."
Characterize every numeric distribution you analyze:
Moving averages to smooth noise:
# 7-day moving average (good for daily data with weekly seasonality)
df['ma_7d'] = df['metric'].rolling(window=7, min_periods=1).mean()
# 28-day moving average (smooths weekly AND monthly patterns)
df['ma_28d'] = df['metric'].rolling(window=28, min_periods=1).mean()
Period-over-period comparison :
Growth rates :
Simple growth: (current - previous) / previous
CAGR: (ending / beginning) ^ (1 / years) - 1
Log growth: ln(current / previous) -- better for volatile series
Check for periodic patterns:
For business analysts (not data scientists), use straightforward methods:
Always communicate uncertainty. Provide a range, not a point estimate:
When to escalate to a data scientist : Non-linear trends, multiple seasonalities, external factors (marketing spend, holidays), or when forecast accuracy matters for resource allocation.
Z-score method (for normally distributed data):
z_scores = (df['value'] - df['value'].mean()) / df['value'].std()
outliers = df[abs(z_scores) > 3] # More than 3 standard deviations
IQR method (robust to non-normal distributions):
Q1 = df['value'].quantile(0.25)
Q3 = df['value'].quantile(0.75)
IQR = Q3 - Q1
lower_bound = Q1 - 1.5 * IQR
upper_bound = Q3 + 1.5 * IQR
outliers = df[(df['value'] < lower_bound) | (df['value'] > upper_bound)]
Percentile method (simplest):
outliers = df[(df['value'] < df['value'].quantile(0.01)) |
(df['value'] > df['value'].quantile(0.99))]
Do NOT automatically remove outliers. Instead:
Report what you did : "We excluded 47 records (0.3%) with transaction amounts >$50K, which represent bulk enterprise orders analyzed separately."
For detecting unusual values in a time series:
Use hypothesis testing when you need to determine whether an observed difference is likely real or could be due to random chance. Common scenarios:
| Scenario | Test | When to Use |
|---|---|---|
| Compare two group means | t-test (independent) | Normal data, two groups |
| Compare two group proportions | z-test for proportions | Conversion rates, binary outcomes |
| Compare paired measurements | Paired t-test | Before/after on same entities |
| Compare 3+ group means | ANOVA | Multiple segments or variants |
| Non-normal data, two groups | Mann-Whitney U test | Skewed metrics, ordinal data |
| Association between categories | Chi-squared test | Two categorical variables |
Statistical significance means the difference is unlikely due to chance.
Practical significance means the difference is large enough to matter for business decisions.
A difference can be statistically significant but practically meaningless (common with large samples). Always report:
When you find a correlation, explicitly consider:
What you can say : "Users who use feature X have 30% higher retention" What you cannot say without more evidence : "Feature X causes 30% higher retention"
When you test many hypotheses, some will be "significant" by chance:
A trend in aggregated data can reverse when data is segmented:
You can only analyze entities that "survived" to be in your dataset:
Aggregate trends may not apply to individuals:
Be wary of false precision:
Weekly Installs
311
Repository
GitHub Stars
8.8K
First Seen
Jan 31, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode252
codex241
gemini-cli235
claude-code227
github-copilot224
kimi-cli207
DOCX文件创建、编辑与分析完整指南 - 使用docx-js、Pandoc和Python脚本
41,800 周安装
Entity Framework Core 最佳实践指南 - 数据上下文设计、性能优化、迁移与安全
7,500 周安装
Dataverse Python 高级模式:生产级SDK代码,含错误处理、批量操作与Pandas集成
7,600 周安装
C# XML 注释最佳实践指南 - 提升代码文档质量与可读性
7,500 周安装
Boost Prompt - AI 提示词优化助手 | GitHub Copilot 增强工具 | 提升编程效率
7,600 周安装
AI故事板创作指南:使用inference.sh CLI快速生成电影分镜与镜头脚本
7,500 周安装
SEO内容简报工具 - 数据驱动的内容策略与SERP分析指南
7,500 周安装