Skip to main content
Glama

Sample size calculator

sample_size

Calculate per-group and total sample sizes plus attrition-adjusted recruitment targets for two-group means, proportions, and non-inferiority studies using normal approximations.

Instructions

Sample size for a two-group comparative study using normal approximations (same formulas as the Meta Workbench web calculator). design='means': two independent means (needs diff, sd1, sd2). design='proportions': two independent proportions, pooled-null variance, no continuity correction (needs p1, p2 as fractions). design='noninferiority': continuous (sd1/sd2, expectedDiff, margin) or binary (p1/p2, margin) endpoint. Returns per-group analysable n, total, and the attrition-adjusted recruitment target.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "design": "<design>"
    },
    "name": "sample_size"
  }
}

Input Schema

NameRequiredDescriptionDefault
p1No[proportions] Event proportion group 1, as a fraction 0–1 (for non-inferiority binary: new group)
p2No[proportions] Event proportion group 2, as a fraction 0–1 (for non-inferiority binary: reference group)
sd1No[means] SD group 1 / [noninferiority-means] SD of new group
sd2No[means] SD group 2 / [noninferiority-means] SD of reference group
diffNo[means] Absolute difference to detect
alphaNoSignificance level (default 0.05; non-inferiority uses one-sided alpha, default 0.025)
powerNoPower in percent, e.g. 80 (default 80)
ratioNoAllocation ratio (default 1). Means/proportions: group 2 : group 1. Non-inferiority: reference : new
sidedNoTest sidedness for means/proportions (default 'two'); non-inferiority is always one-sided
designYesStudy design to size
marginNo[noninferiority] Non-inferiority margin (same units as the endpoint; a fraction for binary)
endpointNo[noninferiority] Endpoint type (default 'means')
attritionNoExpected attrition in percent (default 0)
directionNo[noninferiority] Which direction is better (default 'higher')
expectedDiffNo[noninferiority-means] Expected difference, new − reference (default 0)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the statistical method (normal approximation), the variance assumption (pooled-null, no continuity correction), and the non-inferiority default (one-sided alpha 0.025). It also states the return content (per-group analysable n, total, attrition-adjusted recruitment target). It omits error/validation behaviour and any limits on inputs.

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?

It is front-loaded with the method and scope, then branches cleanly by design value, then closes with the return shape; no sentence is filler. It is a dense single paragraph, so scanning the per-design requirements takes some effort, but nothing is redundant.

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 15-parameter tool with only `design` required, the per-design parameter mapping the description supplies is essential and present, as is the output description in the absence of an output schema. Missing are edge-case behaviour (invalid combinations, zero-variance inputs) and explicit statements of which parameters are ignored in each mode.

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%, so the schema already explains every parameter including units, defaults, and design tags, making 3 the baseline. The description adds only the pooled-null/no-continuity-correction detail and the 'fractions 0–1' reminder, most of which is already in the schema descriptions.

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?

The description names the exact computation (sample size for a two-group comparative study using normal approximations) and enumerates the three design modes it supports, so the agent knows precisely what the tool produces. It does not reference the sibling tools (forest_plot, prisma_diagram, rob_traffic_light), but those are unrelated diagram tools, so ambiguity is low.

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 explicitly maps each `design` value to the parameter set required ('means' needs diff/sd1/sd2; 'proportions' needs p1/p2; 'noninferiority' needs margin plus either endpoint form), which is the key routing decision for this tool. It gives no when-not-to-use guidance or note about what to do if assumptions (normality) are violated.

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