{"id":"sample-quantile-check","version":"1.0.0","description":"Check claimed quantiles or percentiles of an exact sample under Hyndman-Fan type 1-9; returns the first mismatch.","supported_operations":["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"],"unsupported_operations":["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"],"semantics":["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."],"limits":{"max_sample_items":10000,"max_value_chars":40,"max_fraction_digits":30,"max_claims":200},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["sample","method","claims"],"properties":{"sample":{"type":"array","minItems":1,"maxItems":10000,"items":{"anyOf":[{"type":"integer"},{"type":"string","minLength":1,"maxLength":40,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$"}]}},"method":{"type":"string","enum":["type1","type2","type3","type4","type5","type6","type7","type8","type9"]},"claims":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["p","value"],"properties":{"p":{"anyOf":[{"type":"integer"},{"type":"string","minLength":1,"maxLength":40,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}]},"value":{"anyOf":[{"type":"integer"},{"type":"string","minLength":1,"maxLength":40,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}]}}}},"match":{"type":"string","enum":["exact","round_half_even_to_claim_digits"]}}},"output_schema":{"type":"object","additionalProperties":false,"required":["valid","reason","first_discrepancy","claims_checked","method","reference_version"],"properties":{"valid":{"type":"boolean"},"reason":{"type":["string","null"],"enum":[null,"quantile_mismatch"]},"first_discrepancy":{"type":["object","null"],"additionalProperties":false,"required":["index","p","claimed","actual","actual_rounded","lower_rank","upper_rank","weight"],"properties":{"index":{"type":"integer","minimum":0},"p":{"type":"string"},"claimed":{"type":"string"},"actual":{"type":"string"},"actual_rounded":{"type":["string","null"]},"lower_rank":{"type":"integer","minimum":1},"upper_rank":{"type":"integer","minimum":1},"weight":{"type":"string"}}},"claims_checked":{"type":"integer","minimum":0},"method":{"type":"string","enum":["type1","type2","type3","type4","type5","type6","type7","type8","type9"]},"reference_version":{"type":"string"}}},"examples":[{"input":{"sample":[15,20,35,40,50],"method":"type7","claims":[{"p":"0.4","value":"29"}]},"output":{"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"}},{"input":{"sample":[15,20,35,40,50],"method":"type6","claims":[{"p":"0.4","value":"29"}]},"output":{"valid":false,"reason":"quantile_mismatch","first_discrepancy":{"index":0,"p":"0.4","claimed":"29","actual":"26","actual_rounded":null,"lower_rank":2,"upper_rank":3,"weight":"0.4"},"claims_checked":1,"method":"type6","reference_version":"Hyndman and Fan (1996) sample quantile definitions 1-9, Am. Stat. 50(4):361-365; r60-sample-statistic-verifiers@1.0.0"}}],"execute_url":"/v1/tools/sample-quantile-check/versions/1.0.0/execute"}