Calculators
Chi-square test (goodness-of-fit / independence) API
Run a chi-square test: goodness-of-fit χ²=Σ(O−E)²/E for a 1-D count vector, or independence on a 2-D contingency table with expected = row·col/total, returning χ², df, an upper-tail p-value and a decision. Auditable: echoes the test type and df. Answers 'is this die fair','chi-square goodness-of-fit','are these two categorical variables independent'.
Price$0.01per request
MethodPOST
Route/v1/calc/stat-chi-square
StatusLive
MIME typeapplication/json
Rate limit120/minute
CacheNo cache
calcstatisticschi-squaregoodness-of-fitindependencecontingencycategoricalp-value
API URL
Integration docshttps://x402.hexl.dev/v1/calc/stat-chi-squareExample request
{
"observed": [
22,
24,
38,
30,
46,
44
],
"expected": [
34,
34,
34,
34,
34,
34
]
}Example response
{
"test": "goodness-of-fit",
"chiSquare": 15.294118,
"df": 5,
"pValue": 0.009177,
"alpha": 0.05,
"rejectNull": true,
"rating": "significant",
"interpretation": "χ²(5)=15.294, p=0.0092; observed differs from expected at alpha=0.05."
}Input schema
{
"type": "object",
"required": [
"observed"
],
"properties": {
"observed": {
"description": "1-D counts (goodness-of-fit) or 2-D table (independence)",
"examples": [
[
22,
24,
38,
30,
46,
44
]
]
},
"expected": {
"type": "array",
"items": {
"type": "number"
},
"description": "optional expected counts; defaults to uniform",
"examples": [
[
34,
34,
34,
34,
34,
34
]
]
},
"alpha": {
"type": "number",
"default": 0.05
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}