Sample quantile check
sample-quantile-check · version 1.0.0 · Numbers & math · free, no key needed
Check claimed quantiles or percentiles of an exact sample under Hyndman-Fan type 1-9; returns the first mismatch.
Use when you need to: check claimed percentile of a sample · verify quartile values against data · validate quantile under hyndman fan type 7.
Decide before calling
Read the versioned contract and the supported scope below. Reuse sample-quantile-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-quantile-check@1.0.0 for check claimed percentile of a sample. 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 percentile of a sample
- verify quartile values against data
- validate quantile under hyndman fan type 7
- check nearest rank percentile claim
- audit excel percentile inc result
- confirm interquartile values for a data set
Not supported
- weighted quantiles or quantiles of grouped data
- theoretical distribution quantiles (normal, t, chi-square)
- choosing a quantile definition for the caller
- Harrell-Davis or kernel quantile estimators
Behavior
- Reference: Hyndman and Fan (1996) definitions 1-9 (the numbering used by R stats::quantile type = 1..9); reference_version is returned with every result.
- The sample (same rules as sample-summary-check: safe integers or ASCII decimal strings) is sorted into x(1) <= ... <= x(n), with x(k) = x(1) for k < 1 and x(k) = x(n) for k > n.
- Q(p) = (1 - g) x(j) + g x(j+1). Types 4-9: j = floor(np + m), g = np + m - j, m = 0, 1/2, p, 1 - p, (p+1)/3, p/4 + 3/8.
- Types 1-2: j = floor(np), h = np - j, g = 1 if h > 0 else 0 (type 1) or 1/2 (type 2). Type 3: j = floor(np - 1/2), g = 0 if np - 1/2 = j and j is even, else 1.
- p is an exact integer, decimal or p/q in [0, 1]; claims are checked in array order; duplicate p values (by value) are invalid_input.
- match (omitted = "exact"): "round_half_even_to_claim_digits" rounds the exact quantile half-to-even to the claimed value's written fractional digits; fraction claims stay exact.
- First mismatch: {index, p, claimed, actual, actual_rounded, lower_rank, upper_rank, weight} with the clamped ranks of x(j) and x(j+1) and g as an exact string.
- Numbers are returned in canonical exact form: integer, terminating decimal without trailing zeros, or reduced p/q.
Input
sample(array of integer or string, required): min items 1; max items 10000method(one of "type1", "type2", "type3", "type4", "type5", "type6", "type7", "type8", "type9", required)claims(array of object, required): min items 1; max items 200match(one of "exact", "round_half_even_to_claim_digits", optional)
Output
valid(boolean, required)reason(one of null, "quantile_mismatch", required)first_discrepancy(object or null, required)claims_checked(integer, required): min 0method(one of "type1", "type2", "type3", "type4", "type5", "type6", "type7", "type8", "type9", required)reference_version(string, required)
Limits
- max sample items: 10000
- max value chars: 40
- max fraction digits: 30
- max claims: 200
Example
Request input:
{
"sample": [
15,
20,
35,
40,
50
],
"method": "type7",
"claims": [
{
"p": "0.4",
"value": "29"
}
]
}
Response:
{
"result": {
"valid": true,
"reason": null,
"first_discrepancy": null,
"claims_checked": 1,
"method": "type7",
"reference_version": "Hyndman and Fan (1996) sample quantile definitions 1-9, Am. Stat. 50(4):361-365; r60-sample-statistic-verifiers@1.0.0"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "sample-quantile-check",
"version": "1.0.0",
"input": {
"sample": [
15,
20,
35,
40,
50
],
"method": "type7",
"claims": [
{
"p": "0.4",
"value": "29"
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/sample-quantile-check/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"sample":[15,20,35,40,50],"method":"type7","claims":[{"p":"0.4","value":"29"}]}'
The machine-readable contract is at /v1/tools/sample-quantile-check/versions/1.0.0.
CLI
node cli.mjs run sample-quantile-check 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Sample summary check: Check claimed count, sum, mean, median, range, variance or SD of an exact sample; returns the first mismatching field.
- Sample histogram check: Check claimed histogram counts, outside count and densities for exact edges and an edge rule; returns the first bad bin.
- Network cut capacity check: Check a claimed s-t cut: source-side membership, the edges crossing it and its capacity, with exact integers.
- Network flow feasibility check: Check a claimed s-t flow for capacity bounds and conservation with exact integers; returns the first bad edge or node.
- Coloring count check: Check a proper indexed coloring and an exact canonical-decimal claim for its number of distinct colors.
- Linear residual check: Check a claimed residual r = b - A x (per component and/or its max norm) exactly for an approximate solution x.