{
  "category": "Statistical functions",
  "display_name": "CHISQ.TEST",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.CHISQ.TEST",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131"
      ],
      "larger_numeric": 0,
      "last_bit": 2,
      "matched": 3,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 5,
      "unread": 0,
      "worst_ulp": 3
    },
    "detail": "Everything else matches (5 in the answer bank and 13 workbook cells). Last-bit means a finite number within 16 ULP of Excel's.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "close",
    "state_label": "Close: last-bit deviations remain",
    "summary": "Close: 2 of 18 recorded answers differ in the last bits, worst 3 ULP",
    "workbook_corpus": {
      "cells": 13,
      "matched": 13
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/distributions.rs#L326-L328"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/distributions::chisq_test_of",
        "ported/chi_f_t_family::truncate_positive_integer",
        "ported/chi_f_t_family::validate_nonnegative_x",
        "ported/chi_f_t_family::chisq_dist_rt_kernel",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_expm1_internal",
        "ported/excel_numeric::expm1_internal_graph",
        "ported/excel_numeric::excel_x87_add",
        "ported/excel_numeric::excel_x87_sub",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_temme_finish",
        "ported/excel_numeric::excel_x87_div",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::add",
        "ported/excel_numeric/x87::sub",
        "ported/excel_numeric/x87::div",
        "ported/excel_numeric/x87_chains::pow2_positive",
        "ported/excel_numeric/x87_chains::pow2",
        "ported/excel_numeric/x87_chains::exp_ext",
        "ported/excel_numeric/x87_chains::exp_with",
        "ported/excel_numeric/x87_chains::excel_exp",
        "ported/excel_numeric/x87_chains::log_with",
        "ported/excel_numeric/x87_chains::excel_log",
        "ported/normal_dist_common::stored_horner",
        "ported/normal_dist_common::erf_approx",
        "ported/normal_dist_common::erfc_upper",
        "ported/special_dist_family::erfc_of_sqrt_half_x",
        "ported/special_dist_family::erfc_kernel",
        "ported/special_dist_family::erfc_precise_kernel",
        "ported/special_math_common::gratio_norm_gamma",
        "ported/special_math_common::gratio_rexp",
        "ported/special_math_common::gratio_rlog",
        "ported/special_math_common::gratio_gam1",
        "ported/special_math_common::gratio",
        "ported/special_math_common::series_prefactor",
        "ported/special_math_common::gratio_after40",
        "ported/special_math_common::gratio_cf",
        "ported/special_math_common::gratio_temme_270",
        "ported/special_math_common::gratio_temme_340",
        "ported/special_math_common::gratio_temme_330",
        "ported/special_math_common::gratio_temme_finish",
        "ported/special_math_common::regularized_gamma_q"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/distributions.rs#L326-L328",
      "state": "close",
      "suite": null,
      "summary": "Close: 2 of 18 recorded answers differ in the last bits, worst 3 ULP"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.CHISQ.TEST.json",
  "name": "CHISQ.TEST",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[CHISQ.DIST.RT](FUNC.CHISQ.DIST.RT.md) evaluates a supplied statistic; [CHISQ.INV.RT](FUNC.CHISQ.INV.RT.md) finds a critical value. [F.TEST](FUNC.F.TEST.md) compares sample variances.\n\n\n",
    "how-to-implement": "\n1. Resolve the two input grids and retain their row and column counts. Propagate a direct scalar argument error before a shape mismatch. Reject unequal shapes.\n2. Set degrees of freedom to `(rows-1)*(columns-1)` when both dimensions exceed one, `columns-1` for one row or `rows-1` for one column. Reject zero degrees.\n3. Traverse paired positions in row order. Propagate a cell error, require two numbers and reject a nonpositive expected value under the current rules.\n4. With ordinary binary64 stores, form `delta=actual-expected`, `square=delta*delta`, `contribution=square/expected` and `statistic=statistic+contribution` from an initial zero.\n5. Evaluate the chi-square right tail at that stored statistic and degree count.\n\nThe starter example contributes `4/10=0.4` from each category, giving statistic 0.8 and one degree. For an independence layout `{12,8;8,12}`, both row totals and both column totals are twenty and the grand total forty, so every expected count is ten. Its four contributions total 1.6, still with one degree because `(2-1)*(2-1)=1`.\n\nKeep admission, statistic reduction and the numerical right-tail routine as separate stages. The loop describes current code; the forward distribution’s last bits and other recorded residuals remain unresolved.\n\n\n",
    "quirks": "\nThe arrays need matching shapes; a mismatch gives `#N/A` in the current wrapper. A one-cell comparison also gives `#N/A` because it supplies no positive degree count. The output is a tail probability, rather than the chi-square statistic itself.\n\nThe current wrapper requires a numeric value at every paired position and returns `#VALUE!` for text, logical or blank cells; it does not compact those cells into a shorter sample. It propagates a direct argument error before comparing shapes, then checks cell errors during traversal. A nonpositive expected count gives `#NUM!` in this code.\n\nFor an independence table, calculate expected counts from row total times column total divided by grand total before calling the function. The function takes those expected values as inputs. Its p-value is conditional on the chosen model and expected table.\n\n\n",
    "sources": "\n- [Microsoft: CHISQ.TEST function](https://support.microsoft.com/en-us/excel/functions/chisq-test-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc implementation](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/ported/statistical_tests_family.rs); implementation steps and the limits identified in the text.\n\n",
    "try-it": "\n`=CHISQ.TEST({12,8},{10,10})` is about `0.37109337`. The statistic is `(12-10)^2/10+(8-10)^2/10=0.8`, with one degree of freedom for a one-row, two-category comparison.\n\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 5 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.CHISQ.TEST.json).",
    "what-it-does": "\n`CHISQ.TEST(actual_range, expected_range)` returns a chi-square right-tail test probability from observed and expected frequencies. Supply the expected counts explicitly; the function does not infer them from labels.\n\n\n"
  },
  "signature": {
    "display": "CHISQ.TEST(actual_range, expected_range)",
    "parameters": [
      {
        "description": null,
        "name": "actual_range",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "expected_range",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 2
      },
      "category": "Statistical functions",
      "classification": {
        "arg_preparation_profile": "RefsVisibleInAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "RefOnly",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Chi-squared test of independence between observed and expected counts, as a probability",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the test for independence",
        "microsoft_url": "https://support.microsoft.com/en-us/office/chisq-test-function-2e8a7861-b14a-4985-aa93-fb88de3f260f"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "bg-BG",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "cs-CZ",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "da-DK",
          "name": "CHI2.TEST"
        },
        {
          "locale": "de-DE",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "el-GR",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "en-AU",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "en-GB",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "en-US",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "es-ES",
          "name": "PRUEBA.CHICUAD"
        },
        {
          "locale": "et-EE",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "fi-FI",
          "name": "CHINELIÖ.TESTI"
        },
        {
          "locale": "fr-FR",
          "name": "CHISQ.TEST*"
        },
        {
          "locale": "he-IL",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "hr-HR",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "hu-HU",
          "name": "KHINÉGYZET.PRÓBA"
        },
        {
          "locale": "id-ID",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "it-IT",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "ja-JP",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "ko-KR",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "lt-LT",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "lv-LV",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "nb-NO",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "nl-NL",
          "name": "CHIKW.TEST"
        },
        {
          "locale": "pl-PL",
          "name": "CHI.TEST"
        },
        {
          "locale": "pt-BR",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "pt-PT",
          "name": "TESTE.CHIQ"
        },
        {
          "locale": "ro-RO",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "ru-RU",
          "name": "ХИ2.ТЕСТ"
        },
        {
          "locale": "sk-SK",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "sl-SI",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "sv-SE",
          "name": "CHI2.TEST"
        },
        {
          "locale": "th-TH",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "tr-TR",
          "name": "KİKARE.TEST"
        },
        {
          "locale": "uk-UA",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "vi-VN",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "zh-CN",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "zh-HK",
          "name": "CHISQ.TEST"
        },
        {
          "locale": "zh-TW",
          "name": "CHISQ.TEST"
        }
      ],
      "signature": {
        "display": "CHISQ.TEST(actual_range, expected_range)",
        "parameters": [
          {
            "description": null,
            "name": "actual_range",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "expected_range",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "CHISQ.TEST",
      "version_marker": null,
      "xlcall": {
        "code": "490",
        "symbol": "xlfChisq_test"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/chisq-test-function-2e8a7861-b14a-4985-aa93-fb88de3f260f"
  },
  "try_it": {
    "formula": "=CHISQ.TEST({12,8},{10,10})"
  },
  "url": "https://handbook.dnacalc.com/functions/CHISQ.TEST.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "5 captured inputs are indexed for this environment. Capture dates: 2026-07-12 to 2026-07-12. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20131",
      "platform": "Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.CHISQ.TEST.json"
      ]
    }
  ]
}