Skip to main content
Glama

nonparametric_test

Perform Wilcoxon, Mann-Whitney, or Kruskal-Wallis tests on CSV/Excel/JSON data to compare paired, two-group, or multi-group samples without normality assumptions. Get p-values, effect sizes, and clear conclusions.

Instructions

nonparametric_test —— 统计推断组 · 非参数检验(工具 26,核心实现)。

docstring = agent 使用说明书,与 statlab_mcp/docs/design/09_inference_batch3.md 同步维护。

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) test (str, "wilcoxon"): wilcoxon(配对)/ mann_whitney(两组独立)/ kruskal_wallis(多组) column (str): test=wilcoxon 时必填(配对的第一组测量) sample2_col (str): test=wilcoxon 时必填(配对第二组测量) group_col (str): test=mann_whitney / kruskal_wallis 时必填(分组列) value_col (str): test=mann_whitney / kruskal_wallis 时必填(数值列) alpha (float, 0.05): 显著性水平 ∈ (0,1) alternative (str, "two_sided"): two_sided / less / greater(仅 wilcoxon 与 mann_whitney 生效;kruskal_wallis 恒为双侧)

口径(设计文档 09 钉死): wilcoxon: scipy.stats.wilcoxon(zero_method="wilcox", correction=False, method="auto")——0 差剔除(zero_method=wilcox 语义);method="auto": 小样本无 ties 用精确分布,否则正态近似;效应量 matched rank-biserial r = 2×(正秩和)/n(n+1) − 1,等价式 1 − 4W/(n(n+1))(W=scipy 返回的较小秩和), 方向以 mean(column − sample2_col) 符号定(column 高为正侧),n=剔除 0 差后的对数。 mann_whitney: scipy.stats.mannwhitneyu(use_continuity=True, method="auto") ——注明 ties 时用正态近似含连续性校正;效应量 rank-biserial r = 2U/(n1·n2) − 1(U=scipy 对 group1 的统计量),方向 group1 高为正侧。 kruskal_wallis: scipy.stats.kruskal——统计量 H(未做 ties 校正,注明); 效应量 epsilon² = H/(N−1)(= (ΣᵢRᵢ²/nᵢ − 3(N+1))/(N−1),N 为总样本量), 近似解释为"组间秩差异占总秩变异的比例"。 结论固定模板:p<α 拒绝 H0 / p≥α 不能拒绝;局限声明(非参检验功效通常低于 参数检验、ties 处理、样本量)。

边界: 样本不足(wilcoxon 有效对数 n<5;mann_whitney 每组 n<2;kruskal 组数 2~20 且每组 n>=2)、差值无变异/常量组、alpha/alternative 非法、NaN/Inf 防御—— 一律中文报错;无图。

示例: nonparametric_test("samples/clean.csv", test="mann_whitney", group_col="category", value_col="score") inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testNowilcoxon
alphaNo
columnNo
file_pathNo
group_colNo
value_colNo
alternativeNotwo_sided
inline_dataNo
sample2_colNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.2.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full weight and delivers exact SciPy functions/methods, tie handling, zero-difference removal, continuity correction, effect-size formulas and direction conventions, fixed conclusion wording, sample-size boundaries, and Chinese error behavior. This goes far beyond what the input schema offers.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The text is long but organized into clear sections (parameters, statistical conventions, boundaries, example, inline data) with front-loaded parameter semantics. Minor internal metadata such as '工具 26' and doc-sync notes add noise but do not prevent quick scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex 9-parameter tool with no output schema, the description covers inputs, edge cases, and behavioral conventions thoroughly. The main gap is the absence of an explicit return-value contract (field names/shape), although the conclusion template and effect-size definitions partially compensate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% and there are no required parameters, so the description is the only source of parameter meaning. It explains every parameter, defaults, allowed values, conditional requirements (e.g., column/sample2_col only for wilcoxon), alpha bounds, alternative applicability, and inline_data shape.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description identifies the tool as nonparametric inference (统计推断组 · 非参数检验) and enumerates the three supported tests: Wilcoxon, Mann-Whitney, and Kruskal-Wallis. This makes the operation and resource clear, and the concrete test names distinguish it from sibling tools like anova_test or chi_square_test.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It maps each supported test to its data scenario (paired, two independent groups, multiple groups) and states conditional parameter requirements. It does not explicitly contrast the tool with sibling hypothesis tests or tell the agent when a parametric alternative would be preferred, though it notes nonparametric tests generally have lower power.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/good-boy4069/statlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server