Skip to main content
Glama

Sample size & power / 样本量计算(设计口径)

sample_size_calculator
Read-only

Sample size & power / 样本量计算(设计口径) | USE WHEN: calculate how many subjects are needed (two means / two proportions / correlation / survival), or solve for power | ALIASES: 样本量, 要做多少例, 需要多少病人, sample size, power calculation, 把握度, 最少例数, n per group | RETURNS: 每组例数与合计

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sd": 6,
      "alpha": 0.05,
      "power": 0.8,
      "effect": 3,
      "dropout": 0.1,
      "sample_type": "两组均数"
    },
    "name": "sample_size_calculator"
  }
}

Input Schema

NameRequiredDescriptionDefault
alphaNo显著性水平,默认 0.05
powerNo把握度,默认 0.8
n_groupsNo组数(整数,默认 2,范围 1~20)。多组比较时样本量按每组分别给出、不是总数;组数越多单组所需例数越大(多重比较校正)。
design_typeNo设计类型,默认 two_sample。可选 two_sample/paired/one_sample/two_proportion/one_proportion/survival/correlation。它决定公式用哪个,传错会算出一个形式正确但含义不对的样本量。
effect_sizeYes预期效应量(连续=Cohen's d,二分类=率差,相关=Pearson r)。这是决定样本量的实质输入,必填
control_rateNo对照组事件率(0~1),仅 outcome_type=binary 时需要。与 p1/p2 二选一:p1/p2 是两组的率,control_rate 只给对照侧。
dropout_rateNo脱落率,默认 0.10
outcome_typeNo结局类型:continuous 连续 / binary 二分类 / correlation 相关,默认 continuous

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / control_rate
      Added value: +{
      +  "description": "对照组事件率(0~1),仅 outcome_type=binary 时需要。与 p1/p2 二选一:p1/p2 是两组的率,control_rate 只给对照侧。",
      +  "type": "number"
      +}
    • addedInput schema / properties / design_type
      Added value: +{
      +  "description": "设计类型,默认 two_sample。可选 two_sample/paired/one_sample/two_proportion/one_proportion/survival/correlation。它决定公式用哪个,传错会算出一个形式正确但含义不对的样本量。",
      +  "type": "string"
      +}
    • changedInput schema / properties / n_groups / description
      Previous value: -"组数,默认 2"New value: +"组数(整数,默认 2,范围 1~20)。多组比较时样本量按每组分别给出、不是总数;组数越多单组所需例数越大(多重比较校正)。"
  2. Changed9 schema fields changed
    • removedInput schema / properties / dropout
      Removed value: -{
      -  "description": "脱落率",
      -  "type": "number"
      -}
    • addedInput schema / properties / dropout_rate
      Added value: +{
      +  "description": "脱落率,默认 0.10",
      +  "type": "number"
      +}
    • removedInput schema / properties / effect
      Removed value: -{
      -  "description": "预期效应量/差值",
      -  "type": "number"
      -}
    • addedInput schema / properties / effect_size
      Added value: +{
      +  "description": "预期效应量(连续=Cohen's d,二分类=率差,相关=Pearson r)。这是决定样本量的实质输入,必填",
      +  "type": "number"
      +}
    • addedInput schema / properties / n_groups
      Added value: +{
      +  "description": "组数,默认 2",
      +  "type": "integer"
      +}
    • addedInput schema / properties / outcome_type
      Added value: +{
      +  "description": "结局类型:continuous 连续 / binary 二分类 / correlation 相关,默认 continuous",
      +  "type": "string"
      +}
    • removedInput schema / properties / sample_type
      Removed value: -{
      -  "description": "计算类型:两组均数/两组率/相关/生存",
      -  "type": "string"
      -}
    • removedInput schema / properties / sd
      Removed value: -{
      -  "description": "标准差",
      -  "type": "number"
      -}
    • changedInput schema / required
      Previous value: -[]New value: +[
      +  "effect_size"
      +]
  3. Added

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false and openWorldHint=false, so the safety profile is covered and the description need only add context. It contributes the return shape ('每组例数与合计', i.e. per-group and total n), which is genuinely useful, but says nothing about defaults being silently applied, rounding, or what happens when design_type and outcome_type disagree — a real risk given the schema's own warning that a wrong design yields a formally valid but meaningless answer.

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 USE WHEN / ALIASES / RETURNS segmentation is front-loaded and scannable, and the RETURNS line is the highest-value sentence. The alias list is long and partly redundant with the title, but it earns its space as retrieval surface for a bilingual tool, so only minor trimming is warranted.

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 an 8-parameter, read-only computation tool with full schema coverage and no output schema, the definition supplies purpose, triggers, and a one-line return contract — enough for correct invocation. The remaining gap is behavioral rather than structural: nothing warns that the effect_size scale must match the chosen design, which is the most likely way to get a plausible-but-wrong number.

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

Parameters3/5

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

Schema description coverage is 100% and the per-parameter descriptions are unusually rich — they already explain effect_size semantics, design_type's formula-selection role, n_groups' multiplicity correction, and the control_rate vs p1/p2 choice. The description adds no parameter-level meaning beyond that, so this is the baseline 3; the schema is doing all the disambiguation work.

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

Purpose4/5

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

States a specific verb and resource ('calculate how many subjects are needed') and enumerates the supported designs (two means / two proportions / correlation / survival) plus the inverse power solve. It is instantly distinguishable from generic stats tools, but it never names or contrasts with the sibling animal_sample_size, so the boundary between human and animal sample-size tools is left implicit.

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 'USE WHEN' clause gives concrete triggers (how many subjects, or solve for power) and the ALIASES block captures the Chinese/English phrasings users actually type, which is real routing value. It stops short of exclusions — there is no 'do not use for X, use animal_sample_size instead' — so an agent facing an animal-study request gets no explicit redirect.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources