{
  "category": "Compatibility",
  "display_name": "NEGBINOMDIST",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.NEGBINOMDIST",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131",
        "?"
      ],
      "larger_numeric": 335,
      "last_bit": 1254,
      "matched": 215,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 1804,
      "unread": 0,
      "worst_ulp": 249
    },
    "detail": "Of 1,845 recorded answers (1,804 in the answer bank and 41 workbook cells), 1,607 do not match: 335 differ by more than 16 ULP, 1,272 differ by at most 16 ULP.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "differs",
    "state_label": "Known larger differences",
    "summary": "Known larger differences on 1,607 of 1,845 recorded answers",
    "workbook_corpus": {
      "cells": 41,
      "last_bit": 18,
      "matched": 23,
      "worst_ulp": 10
    }
  },
  "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#L302-L305"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/distributions::nums",
        "ported/discrete_dist::stirling_error",
        "ported/discrete_dist::deviance",
        "ported/discrete_dist::binom_mass",
        "ported/discrete_dist::finite",
        "ported/discrete_dist::negbinom_mass",
        "ported/discrete_dist::negbinom_dist_kernel",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_x87_add",
        "ported/excel_numeric::excel_x87_sub",
        "ported/excel_numeric::excel_x87_mul",
        "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"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/distributions.rs#L302-L305",
      "state": "differs",
      "suite": null,
      "summary": "Known larger differences on 1,607 of 1,845 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.NEGBINOMDIST.json",
  "name": "NEGBINOMDIST",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[NEGBINOM.DIST](FUNC.NEGBINOM.DIST.md) adds the cumulative option; [BINOM.DIST](FUNC.BINOM.DIST.md) fixes the trial count instead of the success threshold.\n\n\n",
    "how-to-implement": "\nThe mathematical mass for `f` failures before success number `s` is\n\n```text\nchoose(f+s-1,f) * p^s * (1-p)^f\n```\n\nThe last trial is fixed as a success. Choose the positions of the other `s-1` successes among the preceding `f+s-1` trials. Thus for `f=2,s=2,p=0.5`, the possible success/failure patterns are `SFFS`, `FSFS`, `FFSS`; each has probability `1/16`, giving `3/16` in total.\n\nThe current code composes binomial machinery instead of constructing factorials:\n\n1. Truncate and validate `f,s,p`; retain the endpoint guard above.\n2. For `f=0`, return the public exponential of the ordinary binary64 product `s*LN(p)`. Do not infer the stored product stage of BINOM.DIST’s all-success route for this separate call site.\n3. Otherwise form `n=s+f`, `q=1-p` and the shared binomial mass `b(s;n,p,q)`. Multiply it by `s/n` with the current binary64 division and multiplication.\n4. Apply the finite-result policy. The helper still has recorded numerical and domain discrepancies in the problem report.\n\nFor mathematical summation, adjacent masses satisfy `mass(f+1)=mass(f)*(f+s)/(f+1)*(1-p)`. That recurrence can avoid huge factorials, but its rounding and underflow differ from the current binomial composition. The mass-only legacy function has no cumulative argument; use NEGBINOM.DIST when the probability of at most a failure count is required.\n\n\n",
    "quirks": "\nFailure and success counts are truncated toward zero; the first is failures, not total trials. Negative admitted failures or fewer than one target success gives `#NUM!`. Nonnumeric arguments give `#VALUE!`.\n\nMicrosoft’s written probability guard excludes values outside zero through one. The current helper uses the stricter open interval `0<p<1`, rejecting both endpoints with `#NUM!`. That is a distinction between the written baseline and the current implementation; no new Excel endpoint reading is asserted here. Counts and endpoint guards must be tested separately from the mass formula.\n\n\n",
    "sources": "\n- [Microsoft: NEGBINOMDIST function](https://support.microsoft.com/en-us/excel/functions/negbinomdist-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/discrete_dist.rs); implementation steps and the limits identified in the text.\n- [Remaining numerical and domain rows](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/docs/generated/problem-functions.md).\n\n",
    "try-it": "\n`=NEGBINOMDIST(2,2,0.5)` is about `0.1875`. The final success occupies the fourth trial; the first three positions contain one success in three possible arrangements, each four-trial sequence having probability `1/16`.\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| 19929 | Windows, bitness not recorded, CPU not recorded | 138 |\n| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 1,804 |\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.NEGBINOMDIST.json).",
    "what-it-does": "\n`NEGBINOMDIST(number_f,number_s,probability_s)` returns the probability of exactly `number_f` failures before the specified number of successes. The final trial is a success. This compatibility form returns a mass, with no cumulative switch.\n\n\n"
  },
  "signature": {
    "display": "NEGBINOMDIST(number_f, number_s, probability_s)",
    "parameters": [
      {
        "description": null,
        "name": "number_f",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "number_s",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "probability_s",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 3,
        "min": 3
      },
      "category": "Compatibility",
      "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": "Negative binomial probability (older form)",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the negative binomial distribution",
        "microsoft_url": "https://support.microsoft.com/en-us/office/negbinomdist-function-f59b0a37-bae2-408d-b115-a315609ba714"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "bg-BG",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "cs-CZ",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "da-DK",
          "name": "NEGBINOMFORDELING"
        },
        {
          "locale": "de-DE",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "el-GR",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "en-AU",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "en-GB",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "en-US",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "es-ES",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "et-EE",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "fi-FI",
          "name": "BINOMIJAKAUMA.NEG"
        },
        {
          "locale": "fr-FR",
          "name": "LOI.BINOMIALE.NEG*"
        },
        {
          "locale": "he-IL",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "hr-HR",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "hu-HU",
          "name": "NEGBINOM.ELOSZL"
        },
        {
          "locale": "id-ID",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "it-IT",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "ja-JP",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "ko-KR",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "lt-LT",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "lv-LV",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "nb-NO",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "nl-NL",
          "name": "NEG.BINOM.VERD"
        },
        {
          "locale": "pl-PL",
          "name": "ROZKŁAD.DWUM.PRZEC"
        },
        {
          "locale": "pt-BR",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "pt-PT",
          "name": "DIST.BIN.NEG"
        },
        {
          "locale": "ro-RO",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "ru-RU",
          "name": "ОТРБИНОМРАСП"
        },
        {
          "locale": "sk-SK",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "sl-SI",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "sv-SE",
          "name": "NEGBINOMFÖRD"
        },
        {
          "locale": "th-TH",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "tr-TR",
          "name": "NEGBİNOMDAĞ işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "vi-VN",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "zh-CN",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "zh-HK",
          "name": "NEGBINOMDIST"
        },
        {
          "locale": "zh-TW",
          "name": "NEGBINOMDIST"
        }
      ],
      "signature": {
        "display": "NEGBINOMDIST(number_f, number_s, probability_s)",
        "parameters": [
          {
            "description": null,
            "name": "number_f",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "number_s",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "probability_s",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "NEGBINOMDIST",
      "version_marker": null,
      "xlcall": {
        "code": "292",
        "symbol": "xlfNegbinomdist"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/negbinomdist-function-f59b0a37-bae2-408d-b115-a315609ba714"
  },
  "try_it": {
    "formula": "=NEGBINOMDIST(2,2,0.5)"
  },
  "url": "https://handbook.dnacalc.com/functions/NEGBINOMDIST.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "138 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 19929",
      "platform": "Windows, bitness not recorded, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.NEGBINOMDIST.json"
      ]
    },
    {
      "behaviour": "1,804 captured inputs are indexed for this environment. Capture dates: 2026-07-16 to 2026-07-18. 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.NEGBINOMDIST.json"
      ]
    }
  ]
}