# Sample summary check

`sample-summary-check` · version 1.0.0 · Numbers & math · free, no key needed

Check claimed count, sum, mean, median, range, variance or SD of an exact sample; returns the first mismatching field.

**Use when you need to: check claimed sample mean and variance · verify descriptive statistics claim · validate reported standard deviation against data.**

## Decide before calling

Read the [versioned contract](/v1/tools/sample-summary-check/versions/1.0.0) and the supported scope below. Reuse `sample-summary-check@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `sample-summary-check@1.0.0` for check claimed sample mean and variance. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- check claimed sample mean and variance
- verify descriptive statistics claim
- validate reported standard deviation against data
- did the agent compute the median correctly
- check sample vs population variance claim
- audit summary statistics of a list of numbers
- confirm sum min max range of a sample

## Not supported

- computing statistics without a claim (use a statistics compute tool)
- weighted, trimmed or grouped-data statistics
- skewness, kurtosis or mode
- floating-point tolerance comparisons other than half-even rounding to the claimed digits

## Behavior

- Reference: NIST/SEMATECH e-Handbook of Statistical Methods (2012) 1.3.5.1 (mean, median) and 1.3.5.6 (variance, standard deviation, range); reference_version is returned with every result.
- sample: 1-10000 items, each a JSON safe integer or an ASCII decimal string (no exponent or plus sign, <= 30 fractional digits, <= 40 characters); non-integer JSON numbers are rejected.
- Exact rationals: mean = sum/n; median = middle order statistic or the mean of the two middle ones; range = max - min; sum_squared_deviations = sum (x - mean)^2; variance = that / (n-1) or / n; standard_deviation = sqrt(variance).
- variance_denominator ("n-1" or "n") is required when variance or standard_deviation is claimed, otherwise optional and unused; "n-1" with n = 1 gives valid false, reason statistic_undefined.
- Claims are integers, decimals or p/q fractions compared by exact value; count is a non-negative JSON integer.
- match (omitted = "exact"): "round_half_even_to_claim_digits" rounds the true value half-to-even to each decimal claim's written digits; fraction claims and count stay exact.
- standard_deviation: exact mode needs a rational sqrt equal to the claim; rounding mode compares the correctly rounded integer-square-root result. Irrational sqrt gives actual null and actual_rounded at the claim digits (30 for a fraction claim).
- Fixed comparison order count, sum, min, max, range, mean, median, sum_squared_deviations, variance, standard_deviation; the first mismatch is returned as {field, claimed, actual, actual_rounded} with reason <field>_mismatch.
- actual is canonical: integer, terminating decimal without trailing zeros, or reduced p/q.

## Input

- `sample` (array of integer or string, required): min items 1; max items 10000
- `claim` (object, required)
- `variance_denominator` (one of "n-1", "n", optional)
- `match` (one of "exact", "round_half_even_to_claim_digits", optional)

## Output

- `valid` (boolean, required)
- `reason` (one of null, "count_mismatch", "sum_mismatch", "min_mismatch", "max_mismatch", "range_mismatch", "mean_mismatch", "median_mismatch", "sum_squared_deviations_mismatch", "variance_mismatch", "standard_deviation_mismatch", "statistic_undefined", required)
- `first_discrepancy` (object or null, required)
- `checked_fields` (array of one of "count", "sum", "min", "max", "range", "mean", "median", "sum_squared_deviations", "variance", "standard_deviation", required): max items 10
- `reference_version` (string, required)

## Limits

- max sample items: 10000
- max value chars: 40
- max fraction digits: 30

## Example

Request input:

```json
{
  "sample": [
    2,
    4,
    4,
    4,
    5,
    5,
    7,
    9
  ],
  "variance_denominator": "n",
  "claim": {
    "mean": "5",
    "variance": "4",
    "standard_deviation": "2"
  }
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "first_discrepancy": null,
    "checked_fields": [
      "mean",
      "variance",
      "standard_deviation"
    ],
    "reference_version": "NIST/SEMATECH e-Handbook of Statistical Methods (2012) 1.3.5.1 + 1.3.5.6; r60-sample-statistic-verifiers@1.0.0"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "sample-summary-check",
  "version": "1.0.0",
  "input": {
    "sample": [
      2,
      4,
      4,
      4,
      5,
      5,
      7,
      9
    ],
    "variance_denominator": "n",
    "claim": {
      "mean": "5",
      "variance": "4",
      "standard_deviation": "2"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/sample-summary-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"sample":[2,4,4,4,5,5,7,9],"variance_denominator":"n","claim":{"mean":"5","variance":"4","standard_deviation":"2"}}'
```

The machine-readable contract is at [/v1/tools/sample-summary-check/versions/1.0.0](/v1/tools/sample-summary-check/versions/1.0.0).

### CLI

```sh
node cli.mjs run sample-summary-check 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Sample quantile check](/tools/sample-quantile-check): Check claimed quantiles or percentiles of an exact sample under Hyndman-Fan type 1-9; returns the first mismatch.
- [Linear residual check](/tools/linear-residual-check): Check a claimed residual r = b - A x (per component and/or its max norm) exactly for an approximate solution x.
- [Lp primal feasibility check](/tools/lp-primal-feasibility-check): Check that a claimed LP point satisfies x >= 0 and Ax <= b exactly; report the first violated bound or row.
- [Network cut capacity check](/tools/network-cut-capacity-check): Check a claimed s-t cut: source-side membership, the edges crossing it and its capacity, with exact integers.
- [Sample histogram check](/tools/sample-histogram-check): Check claimed histogram counts, outside count and densities for exact edges and an edge rule; returns the first bad bin.
- [Coloring count check](/tools/coloring-count-check): Check a proper indexed coloring and an exact canonical-decimal claim for its number of distinct colors.
