# Chi-Square Test (Goodness of Fit & Independence)

> Chi-Square Test (Goodness of Fit & Independence) is a paid API for AI agents from stats-tests.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-21).

Runs a chi-square goodness-of-fit test on observed vs expected counts, or a chi-square independence test on a contingency table, returning the test statistic, p-value, degrees of freedom, and effect size.

## Facts

- Endpoint: GET https://stats-tests.x402tookit.com/chi-square-test?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-21
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/chi-square-test-goodness-of-fit-independence-6ea09a25
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_TYY_-ZMmJFkEX7fBjVYhc

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability chi-square-test-goodness-of-fit-independence-6ea09a25
```

Example prompt: Run a chi-square goodness-of-fit test on these observed counts — 5,8,9,8,10,20 — against equal expected frequencies, and tell me the chi-square statistic, p-value, and whether it's significant at the 5% level.

## When to prefer this

Use this endpoint when you need to test categorical data: either whether observed counts match a hypothesized distribution (goodness of fit) or whether two categorical variables are independent (contingency table). Prefer this over Fisher's exact test for larger samples; use Fisher's exact endpoint on this same host for small 2x2 tables where exact p-values are needed.

## Known failure modes

- Missing both 'observed' and 'table' parameters returns an error
- Misformatted table string (wrong delimiter) causes a parse error
- Row lengths inconsistent in the contingency table cause rejection
- All expected counts are zero causes division error
- Very small sample sizes may trigger a warning about cells with expected counts below 5

## How this service works

Chi-square goodness of fit (observed vs expected counts) or independence test on a table, with p-value and effect size.

## Output

Returns the chi-square statistic, degrees of freedom, p-value, expected counts array, per-cell contributions to chi-square, a binary flag for significance at 5%, number of cells with expected counts below 5 (a validity warning), a plain-language summary, and a verdict string.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [],
     "properties": {
      "table": {
       "type": "string",
       "description": "Contingency table for independence, rows separated by semicolons: 12,5;3,10"
      },
      "expected": {
       "type": "string",
       "description": "Expected counts (same length) or leave out for equal expected"
      },
      "observed": {
       "type": "string",
       "description": "Observed counts for goodness of fit, e.g. 5,8,9,8,10,20"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "test": {
       "type": [
        "null",
        "string"
       ]
      },
      "total": {
       "type": [
        "null",
        "number"
       ]
      },
      "pValue": {
       "type": [
        "null",
        "number"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "expected": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "number"
       }
      },
      "chiSquare": {
       "type": [
        "null",
        "number"
       ]
      },
      "disclaimer": {
       "type": [
        "null",
        "string"
       ]
      },
      "notChecked": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "contributions": {
       "type": [
        "array",
        "null"
      
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/chi-square-test-goodness-of-fit-independence-6ea09a25/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from stats-tests.x402tookit.com](https://www.zero.xyz/host/stats-tests.x402tookit.com/llms.txt)
