Skip to main content
Glama

hypothesis_test

Perform one-sample, independent, and paired t-tests with Shapiro normality pre-checks, confidence intervals, and Cohen's d to determine whether observed differences are statistically significant.

Instructions

hypothesis_test —— 统计推断组 · 假设检验(工具 6,核心实现)。

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

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) column (str): 分析列(须为数值列) test (str, "one_sample"): one_sample / independent / paired group_col (str|None): test=independent 时必填,须恰好 2 组且每组 n>=2 sample2_col (str|None): test=paired 时必填(与 column 成对对齐) mu0 (float, 0.0): one_sample 的 H0 假设均值 alternative (str, "two_sided"): two_sided / less / greater alpha (float, 0.05): 显著性水平 ∈ (0,1)

方法(设计文档口径): one_sample -> scipy.stats.ttest_1samp;independent -> ttest_ind(equal_var=False) (Welch's t,规格硬性规定,df 用 Welch-Satterthwaite 公式手算,跨版本稳定); paired -> ttest_rel(差值 = column - sample2_col,成正态预检对象)。 检验前 Shapiro 预检(3<=n<=5000):违反只警示不阻断,可转用 nonparametric_test (Wilcoxon/Mann-Whitney)。 CI 一律双侧(1-alpha,t 分布);效应量 Cohen's d(单样本|mean-mu0|/sd、 独立 pooled sd、配对差值 sd)。结论文案固定模板 p<alpha 拒绝 H0 / p>=alpha 不能拒绝。

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mu0No
testNoone_sample
alphaNo
columnNo
file_pathNo
group_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 provided, the description carries the full burden and delivers: it discloses Welch's t-test as a hard specification with Welch-Satterthwaite df, the Shapiro pre-check for 3<=n<=5000 that warns but does not block, always two-sided CI construction, Cohen's d formulas per design, and the exact conclusion wording template. This is exceptional disclosure of statistical behavior beyond what any structured field could convey.

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 description is long but well-sectioned into parameters, methods, examples, and inline-data notes, with critical constraints front-loaded and worked usage examples included. It loses a point for meta-content that doesn't help invocation, such as the doc-sync maintenance note and the deferral of inline_data limits to an external SPEC.md section.

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 9-parameter tool with no annotations and no output schema, the description covers parameters, statistical methods, pre-check behavior, fallback paths, output highlights (CI, Cohen's d, conclusion template), and examples. The remaining gaps are the absence of a full result-structure specification and error-handling behavior, plus reliance on external docs for inline_data limits.

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 description coverage is 0%, so the description must fully compensate, and it does: every one of the 9 parameters is documented with types, defaults, and constraints (column must be numeric, group_col exactly 2 groups with n>=2, alpha in (0,1), sample2_col paired-aligned). It even documents inline_data's two accepted shapes and its mutual exclusivity with file_path, which the bare array/object union in the schema leaves opaque.

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 opening line identifies it as "统计推断组 · 假设检验(工具 6,核心实现)" — a hypothesis testing tool in the inference group — and the body enumerates the three supported variants (one_sample, independent, paired) with their statistical methods. This clearly separates it from sibling tools like normality_test, anova_test, and chi_square_test, which address different inferential questions.

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?

The description gives concrete selection context: group_col is required and must have exactly 2 groups for independent, sample2_col for paired, and mu0 for one_sample. It also explicitly names nonparametric_test (Wilcoxon/Mann-Whitney) as the fallback when the Shapiro pre-check is violated. It stops short of full when-not routing against siblings like anova_test for 3+ groups, so it earns 4 rather than 5.

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