{
  "category": "Compatibility",
  "display_name": "CHITEST",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.CHITEST",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 7 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 7 recorded answers",
    "workbook_corpus": {
      "cells": 7,
      "matched": 7
    }
  },
  "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#L329-L331"
      ],
      "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#L329-L331",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 7 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.CHITEST.json",
  "name": "CHITEST",
  "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: CHITEST function](https://support.microsoft.com/en-us/excel/functions/chitest-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`=CHITEST({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": "\nNo same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.\n\n\n",
    "what-it-does": "\n`CHITEST(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. CHITEST is the compatibility spelling.\n\n\n"
  },
  "signature": {
    "display": "CHITEST(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": "Compatibility",
      "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 (older form of CHISQ.TEST)",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the test for independence",
        "microsoft_url": "https://support.microsoft.com/en-us/office/chitest-function-981ff871-b694-4134-848e-38ec704577ac"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "CHITEST"
        },
        {
          "locale": "bg-BG",
          "name": "CHITEST"
        },
        {
          "locale": "cs-CZ",
          "name": "CHITEST"
        },
        {
          "locale": "da-DK",
          "name": "CHITEST"
        },
        {
          "locale": "de-DE",
          "name": "CHITEST"
        },
        {
          "locale": "el-GR",
          "name": "CHITEST"
        },
        {
          "locale": "en-AU",
          "name": "CHITEST"
        },
        {
          "locale": "en-GB",
          "name": "CHITEST"
        },
        {
          "locale": "en-US",
          "name": "CHITEST"
        },
        {
          "locale": "es-ES",
          "name": "PRUEBA.CHI"
        },
        {
          "locale": "et-EE",
          "name": "CHITEST"
        },
        {
          "locale": "fi-FI",
          "name": "CHITESTI"
        },
        {
          "locale": "fr-FR",
          "name": "TEST.KHIDEUX*"
        },
        {
          "locale": "he-IL",
          "name": "CHITEST"
        },
        {
          "locale": "hr-HR",
          "name": "CHITEST"
        },
        {
          "locale": "hu-HU",
          "name": "KHI.PRÓBA"
        },
        {
          "locale": "id-ID",
          "name": "CHITEST"
        },
        {
          "locale": "it-IT",
          "name": "CHITEST"
        },
        {
          "locale": "ja-JP",
          "name": "CHITEST"
        },
        {
          "locale": "ko-KR",
          "name": "CHITEST"
        },
        {
          "locale": "lt-LT",
          "name": "CHITEST"
        },
        {
          "locale": "lv-LV",
          "name": "CHITEST"
        },
        {
          "locale": "nb-NO",
          "name": "CHITEST"
        },
        {
          "locale": "nl-NL",
          "name": "CHI.TOETS"
        },
        {
          "locale": "pl-PL",
          "name": "TEST.CHI"
        },
        {
          "locale": "pt-BR",
          "name": "QUITEST"
        },
        {
          "locale": "pt-PT",
          "name": "TESTE.CHI"
        },
        {
          "locale": "ro-RO",
          "name": "CHITEST"
        },
        {
          "locale": "ru-RU",
          "name": "ХИ2ТЕСТ"
        },
        {
          "locale": "sk-SK",
          "name": "CHITEST"
        },
        {
          "locale": "sl-SI",
          "name": "CHITEST"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "CHITEST"
        },
        {
          "locale": "sv-SE",
          "name": "CHI2TEST"
        },
        {
          "locale": "th-TH",
          "name": "CHITEST"
        },
        {
          "locale": "tr-TR",
          "name": "KİKARETEST işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "CHITEST"
        },
        {
          "locale": "vi-VN",
          "name": "CHITEST"
        },
        {
          "locale": "zh-CN",
          "name": "CHITEST"
        },
        {
          "locale": "zh-HK",
          "name": "CHITEST"
        },
        {
          "locale": "zh-TW",
          "name": "CHITEST"
        }
      ],
      "signature": {
        "display": "CHITEST(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": "CHITEST",
      "version_marker": null,
      "xlcall": {
        "code": "306",
        "symbol": "xlfChitest"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/chitest-function-981ff871-b694-4134-848e-38ec704577ac"
  },
  "try_it": {
    "formula": "=CHITEST({12,8},{10,10})"
  },
  "url": "https://handbook.dnacalc.com/functions/CHITEST.html",
  "variants": [],
  "versions": []
}