{
  "category": "Statistical functions",
  "display_name": "T.DIST.2T",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.T.DIST.2T",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Everything else matches (4 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: 1 of 4 recorded answers differ in the last bits, worst 11 ULP",
    "workbook_corpus": {
      "cells": 4,
      "last_bit": 1,
      "matched": 3,
      "worst_ulp": 11
    }
  },
  "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#L170-L173"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/distributions::nums",
        "ported/chi_f_t_family::truncate_positive_integer",
        "ported/chi_f_t_family::validate_nonnegative_x",
        "ported/chi_f_t_family::t_dist_2t_kernel",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_x87_add",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_mul_add",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::add",
        "ported/special_math_common::bratio_ftoi",
        "ported/special_math_common::bratio_spmpar1",
        "ported/special_math_common::bratio_exparg",
        "ported/special_math_common::bratio_esum",
        "ported/special_math_common::bratio_esum20",
        "ported/special_math_common::bratio_alnrel",
        "ported/special_math_common::bratio_rlog1",
        "ported/special_math_common::bratio_gam1",
        "ported/special_math_common::bratio_gamln1",
        "ported/special_math_common::bratio_gamln",
        "ported/special_math_common::bratio_algdiv",
        "ported/special_math_common::bratio_bcorr",
        "ported/special_math_common::bratio_gsumln",
        "ported/special_math_common::bratio_betaln",
        "ported/special_math_common::bratio_betaln_60",
        "ported/special_math_common::bratio_erf_nswc",
        "ported/special_math_common::bratio_erfc1",
        "ported/special_math_common::bratio_rexp",
        "ported/special_math_common::bratio_psi",
        "ported/special_math_common::bratio_fpser",
        "ported/special_math_common::bratio_apser",
        "ported/special_math_common::bratio_bpser",
        "ported/special_math_common::bratio_bup",
        "ported/special_math_common::bratio_brcomp",
        "ported/special_math_common::bratio_brcmp1",
        "ported/special_math_common::bratio_bfrac",
        "ported/special_math_common::bratio_bgrat",
        "ported/special_math_common::bratio_grat1",
        "ported/special_math_common::bratio_basym",
        "ported/special_math_common::bratio"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/distributions.rs#L170-L173",
      "state": "close",
      "suite": null,
      "summary": "Close: 1 of 4 recorded answers differ in the last bits, worst 11 ULP"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.T.DIST.2T.json",
  "name": "T.DIST.2T",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n- **`TDIST(x, ν, 2)`** is the legacy spelling of this surface. Caution: the Handbook's\n  alias-pairing record for the legacy/modern collapse names `TDIST` and `T.DIST.RT` as one of\n  its five pairs — that is the **one-tail** correspondence. `T.DIST.2T` is not a subject of that\n  record, and no evidence in the Handbook's record bears on whether `TDIST(x, ν, 2)` and\n  `T.DIST.2T(x, ν)` publish the same bits. They are documented to compute the same number; that\n  is not the same statement.\n- **[T.DIST.RT](FUNC.T.DIST.RT.md)** — exactly half of this value for `x ≥ 0`.\n- **[T.DIST](FUNC.T.DIST.md)** — the left-tail CDF and the density.\n- **[T.INV.2T](FUNC.T.INV.2T.md)** is this function's inverse, and Microsoft's `T.INV.2T` page\n  says so explicitly: it seeks the `x` with `T.DIST.2T(x, ν) = probability`, and states that\n  `T.INV.2T`'s precision depends on `T.DIST.2T`'s. **[T.INV](FUNC.T.INV.md)** inverts `T.DIST`\n  instead; confusing the two is the single most common error in this corner of Excel, because\n  both are called \"the inverse of the t-distribution\" in ordinary speech.\n- **`CHISQ.DIST.RT`** is the same shape of object for a different distribution, and\n  **`ERFC`** is the ν → ∞ limit up to the `sqrt 2` scaling.\n- **`T.TEST`** with `tails = 2` is the packaged consumer of this quantity.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nThe two-tail area is the cleanest of the three t surfaces to compute, because in the beta\nparameterization it *is* `I_{ν/(ν+x²)}(ν/2, ½)` with no prefactor and no complementation. An\nimplementation that computes it directly inherits the full relative accuracy of its incomplete\nbeta routine across the whole tail.\n\nThe traps are the ones the identity invites rather than the ones the formula contains:\n\n1. **Do not compute it as `2 * (1 − T.DIST(x, ν, TRUE))`.** The inner subtraction destroys the\n   tail before the doubling can restore anything.\n2. **Do not compute the central probability as `1 − T.DIST.2T(x, ν)`** for small `x`. That is\n   the same mistake mirrored, and it is the one a spreadsheet user is likelier to make, because\n   Excel offers no surface for the central probability.\n3. **Argument reduction.** `z = ν/(ν + x²)` should be formed so that neither `x²` overflows nor\n   the small complement `x²/(ν + x²)` is lost. Keeping the complement and calling a\n   complementary incomplete-beta entry point handles both.\n\nFor the continued-fraction evaluation of `I_z(a, b)` the standard reference is Numerical\nRecipes' `betacf`, with the reflection applied so the fraction converges quickly; Cephes'\n`incbet` and Boost.Math's `ibeta`/`ibetac` are the production treatments worth reading. For\ninteger ν, A&S 26.7.3–26.7.4 give finite closed forms, and A&S 26.7 also tabulates the\npercentage points that a spreadsheet is standing in for.\n\nNothing here is a claim about Excel's algorithm. The Handbook does not know it.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`, a probability in `(0, 1]`.\n\n- **`x = 0`** is exactly 1 — one of only two exact values this surface has, and free to check.\n- **Large `x`** gives a small `p`-value decaying like `x^(−ν)`. As with `T.DIST.RT`, the value\n  stays representable and informative deep into the tail *provided* it is not formed by\n  subtraction from one.\n- **Small `x`**, near zero, is the opposite hazard: here the answer is close to 1, and the\n  interesting quantity is `1 − T.DIST.2T(x, ν)`, which no Excel surface exposes directly.\n  A reader wanting the central probability accurately should use\n  `T.DIST(x, ν, TRUE) − T.DIST(−x, ν, TRUE)`, or, better, `2·T.DIST(x, ν, TRUE) − 1` — and\n  should know that all three routes lose digits near `x = 0`.\n- **The doubling identity.** `T.DIST.2T(x, ν) = 2 · T.DIST.RT(x, ν)` is exact in real\n  arithmetic, and multiplication by two is exact in binary floating point. So if Excel computes\n  the two surfaces from one internal quantity, the published bits must satisfy the identity\n  exactly, and if they do not, the two surfaces have different internals. That is a rare\n  situation: a metamorphic probe whose *failure* is as informative as its success, requiring no\n  external oracle.\n\n\n\n### Errors\n\n\nAs documented on Microsoft's `T.DIST.2T` page:\n\n| Error | Documented condition |\n|---|---|\n| `#VALUE!` | Any argument is nonnumeric. |\n| `#NUM!` | `deg_freedom < 1`. |\n| `#NUM!` | `x < 0`. |\n\nErrors in either argument propagate under the universal coercion rule. The Handbook has not\nverified any of this against Excel.\n\n\n",
    "sources": "\n- Microsoft, \"T.DIST.2T function\" —\n  <https://support.microsoft.com/en-us/office/t-dist-2t-function-198e9340-e360-4230-bd21-f52f22ff5c28>\n  (syntax, both arguments required, and the three documented error conditions: `#VALUE!` for\n  nonnumeric arguments, `#NUM!` for `deg_freedom < 1`, `#NUM!` for `x < 0`). Retrieved for this\n  page.\n- Microsoft, \"T.INV.2T function\" — the statement that `T.INV.2T` searches iteratively for the\n  `x` with `T.DIST.2T(x, ν) = probability` and that its precision depends on this surface's.\n- Handbook evidence record `EV-DIST-0011` — cited here only to establish that its five-pair\n  legacy/modern collapse covers `TDIST`/`T.DIST.RT` and **not** this surface.\n- M. Abramowitz and I. A. Stegun, *Handbook of Mathematical Functions*, section 26.7.\n- W. H. Press et al., *Numerical Recipes*, incomplete beta function; Cephes `incbet`;\n  Boost.Math `ibeta` / `ibetac`.\n- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md).\n- Handbook projections `data/functions/FUNC.T.DIST.2T.json`, `data/presence/FUNC.T.DIST.2T.json`\n  and `data/battery/FUNC.T.DIST.2T.json`.\n\n",
    "version-differences": "No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.",
    "what-it-does": "\n`T.DIST.2T(x, deg_freedom)` returns the **two-tailed** area of Student's *t*-distribution with\nν degrees of freedom:\n\n    T.DIST.2T(x, ν) = P(|T| > x) = 2 · P(T > x) = 2 · (1 − F(x; ν))\n\nfor `x ≥ 0`, where `F` is the cumulative distribution function given on\n[T.DIST](FUNC.T.DIST.md#what-it-computes). Because the t-distribution is symmetric about zero,\nthe two tails are equal and the factor of two is exact rather than an approximation.\n\nIn terms of the regularized incomplete beta function, again exactly:\n\n    T.DIST.2T(x, ν) = I_{ν/(ν+x²)}(ν/2, ½)\n\n— note that the `½` prefactor that appears in the one-tail form has cancelled against the\ndoubling. The two-tail area is, in the beta parameterization, the *simpler* object of the three\nt surfaces.\n\nDomain and range: `x ≥ 0` (Microsoft documents `#NUM!` below zero), ν > 0. The value falls\nstrictly from 1 at `x = 0` to 0 as `x → ∞`. `T.DIST.2T(0, ν) = 1` exactly, for every ν: the\nwhole distribution is more than zero away from zero in absolute value, apart from a null set.\n\nElementary closed forms at the small integer degrees of freedom:\n\n| ν | `T.DIST.2T(x, ν)` for `x ≥ 0` |\n|---|---|\n| 1 | `1 − 2·arctan(x)/π` |\n| 2 | `1 − x / sqrt(x² + 2)` |\n| ν → ∞ | `2(1 − Φ(x))` = `ERFC(x/sqrt 2)` |\n\nThat ν = 2 row is worth pausing on: the two-tail t-distribution at two degrees of freedom is an\n*elementary rational-algebraic* function, computable to the last bit with a square root and a\ndivision. Anything an implementation publishes there can be checked against arithmetic.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Required |\n|---|---|---|\n| `x` | The numeric value at which the distribution is evaluated. Documented as non-negative. | Yes |\n| `deg_freedom` | ν, \"an integer indicating the number of degrees of freedom\" (Microsoft). | Yes |\n\n`x < 0` is documented as `#NUM!`. This is the one member of the modern t trio that keeps the\nlegacy `TDIST` domain restriction, and it is worth knowing *why* it is not merely legacy\nbaggage: `P(|T| > x)` for negative `x` is identically 1, so the natural extension is a constant\nand carries no information. Refusing it is a defensible design choice rather than an oversight —\nthough it does mean `T.DIST.2T` is not a total function on the reals the way `T.DIST.RT` is\ndocumented to be.\n\nThe page describes `deg_freedom` as an integer and does not say what a non-integer value does.\nThe inverse pages (`T.INV`, `T.INV.2T`) document truncation for the same parameter; the three\n`T.DIST*` pages are silent.\n\nNumeric slots take ordinary to-number coercion; see\n[Coercion and lifting](../model/02-coercion-and-lifting.md).\n\n\n"
  },
  "signature": {
    "display": "T.DIST.2T(x, deg_freedom)",
    "parameters": [
      {
        "description": null,
        "name": "x",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "deg_freedom",
        "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": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "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": "Two-tailed probability of Student's t distribution",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the Percentage Points (probability) for the Student t-distribution",
        "microsoft_url": "https://support.microsoft.com/en-us/office/t-dist-2t-function-198e9340-e360-4230-bd21-f52f22ff5c28"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "T.DIST.2T"
        },
        {
          "locale": "bg-BG",
          "name": "T.DIST.2T"
        },
        {
          "locale": "cs-CZ",
          "name": "T.DIST.2T"
        },
        {
          "locale": "da-DK",
          "name": "T.FORDELING.2T"
        },
        {
          "locale": "de-DE",
          "name": "T.DIST.2T"
        },
        {
          "locale": "el-GR",
          "name": "T.DIST.2T"
        },
        {
          "locale": "en-AU",
          "name": "T.DIST.2T"
        },
        {
          "locale": "en-GB",
          "name": "T.DIST.2T"
        },
        {
          "locale": "en-US",
          "name": "T.DIST.2T"
        },
        {
          "locale": "es-ES",
          "name": "DISTR.T.2C"
        },
        {
          "locale": "et-EE",
          "name": "T.DIST.2T"
        },
        {
          "locale": "fi-FI",
          "name": "T.JAKAUMA.2S"
        },
        {
          "locale": "fr-FR",
          "name": "LOI.STUDENT.BILATERALE*"
        },
        {
          "locale": "he-IL",
          "name": "T.DIST.2T"
        },
        {
          "locale": "hr-HR",
          "name": "T.DIST.2T"
        },
        {
          "locale": "hu-HU",
          "name": "T.ELOSZLÁS.2SZ"
        },
        {
          "locale": "id-ID",
          "name": "T.DIST.2T"
        },
        {
          "locale": "it-IT",
          "name": "T.DIST.2T"
        },
        {
          "locale": "ja-JP",
          "name": "T.DIST.2T"
        },
        {
          "locale": "ko-KR",
          "name": "T.DIST.2T"
        },
        {
          "locale": "lt-LT",
          "name": "T.DIST.2T"
        },
        {
          "locale": "lv-LV",
          "name": "T.DIST.2T"
        },
        {
          "locale": "nb-NO",
          "name": "T.DIST.2T"
        },
        {
          "locale": "nl-NL",
          "name": "T.DIST.2T"
        },
        {
          "locale": "pl-PL",
          "name": "ROZKŁ.T.DS"
        },
        {
          "locale": "pt-BR",
          "name": "T.DIST.2T"
        },
        {
          "locale": "pt-PT",
          "name": "DIST.T.2C"
        },
        {
          "locale": "ro-RO",
          "name": "T.DIST.2T"
        },
        {
          "locale": "ru-RU",
          "name": "СТЬЮДЕНТ.РАСП.2Х"
        },
        {
          "locale": "sk-SK",
          "name": "T.DIST.2T"
        },
        {
          "locale": "sl-SI",
          "name": "T.DIST.2T"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "T.DIST.2T"
        },
        {
          "locale": "sv-SE",
          "name": "T.FÖRD.2T"
        },
        {
          "locale": "th-TH",
          "name": "T.DIST.2T"
        },
        {
          "locale": "tr-TR",
          "name": "T.DAĞ.2K"
        },
        {
          "locale": "uk-UA",
          "name": "T.DIST.2T"
        },
        {
          "locale": "vi-VN",
          "name": "T.DIST.2T"
        },
        {
          "locale": "zh-CN",
          "name": "T.DIST.2T"
        },
        {
          "locale": "zh-HK",
          "name": "T.DIST.2T"
        },
        {
          "locale": "zh-TW",
          "name": "T.DIST.2T"
        }
      ],
      "signature": {
        "display": "T.DIST.2T(x, deg_freedom)",
        "parameters": [
          {
            "description": null,
            "name": "x",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "deg_freedom",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "T.DIST.2T",
      "version_marker": null,
      "xlcall": {
        "code": "513",
        "symbol": "xlfT_dist_2t"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/t-dist-2t-function-198e9340-e360-4230-bd21-f52f22ff5c28"
  },
  "try_it": {
    "formula": "=T.DIST.2T(1,10)"
  },
  "url": "https://handbook.dnacalc.com/functions/T.DIST.2T.html",
  "variants": [],
  "versions": []
}