{
  "category": "Statistical functions",
  "display_name": "QUARTILE.EXC",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.QUARTILE.EXC",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 5 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 5 recorded answers",
    "workbook_corpus": {
      "cells": 5,
      "matched": 5
    }
  },
  "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/statistics.rs#L307-L307"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/statistics::list",
        "catalogue/statistics::quartile",
        "ported/percentile_common::percentile_inc_kernel",
        "ported/percentile_common::percentile_exc_kernel",
        "ported/percentile_common::interpolate_sorted"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L307-L307",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 5 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.QUARTILE.EXC.json",
  "name": "QUARTILE.EXC",
  "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- **[QUARTILE.INC](FUNC.QUARTILE.INC.md)** is the inclusive sibling, Hyndman–Fan type 7 and the\n  default of R and NumPy. It admits `quart` `0` through `4`, is defined for every non-empty\n  sample, and returns a narrower interquartile range. The two agree only at `quart = 2`. Neither\n  supersedes the other.\n- **`QUARTILE`**, the legacy Compatibility-category name, corresponds to the\n  *inclusive* convention, not this one. `QUARTILE.EXC` has no legacy predecessor: it was added\n  when the dotted names arrived, because the exclusive convention was not previously available in\n  Excel at all. That asymmetry is worth stating, since it means the `.INC`/`.EXC` pair is not a\n  renaming of one old function into two — it is one old function plus one genuinely new one.\n- **[MEDIAN](FUNC.MEDIAN.md)** is the `quart = 2` case and the point of agreement with\n  `QUARTILE.INC`.\n- **[SMALL](FUNC.SMALL.md) and [LARGE](FUNC.LARGE.md)** return order statistics without\n  interpolation, and are what you want if the answer must be a value that actually occurs.\n- Readers reach for `QUARTILE.EXC` expecting \"the quartile excluding the median\", which is a\n  third, different convention (Tukey's hinges, Hyndman–Fan type 2-ish behaviour on odd `n`). The\n  `EXC` does not refer to excluding the median; it refers to the probability interval being open\n  at both ends.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n**The rank arithmetic is exact.** `h = k*(n+1)` with `k` in `{1/4, 1/2, 3/4}` — all dyadic\nrationals, exactly representable in binary64 — and `n+1` a small integer. The product is exact\nfor every `n` within range, so `floor(h)` and `h - floor(h)` are exact and the branch on\n`h` integral versus fractional is never a near-miss. This is a real advantage of quartiles over\ngeneral percentiles: `PERCENTILE.EXC` with `k = 0.1` computes `0.1*(n+1)` from a `k` that is not\nexactly one tenth, and its floor can therefore differ from the mathematically intended one at\nvalues of `n` where the product lands adjacent to an integer. `QUARTILE.EXC` cannot hit that\nclass of bug.\n\n**The interpolation** is evaluated as `lower + g*(upper - lower)` rather than\n`(1-g)*lower + g*upper`. The two are algebraically equal and differ in floating point. The form\nused is monotone in `g` and stays inside the bracket for `lower <= upper`, which is the property\na quantile needs; it can round short of `upper` at `g` near `1`, but the `g = 0` path returns\n`x_(j)` directly so the exact-endpoint case is not routed through the interpolation at all.\n\n**Where the answers actually differ from a competitor.** The gap between type 6 and type 7 at\n`quart = 1` is `(x_(j+1) - x_(j))` scaled by a rank difference of `(n+1)/4 - (1 + (n-1)/4)`,\nwhich is `(2 - n)/4 + …` — in words, it shrinks like `1/n`. On a large sample the two conventions\nconverge; on a sample of four or five they can differ by most of a gap between adjacent\nobservations. Every disagreement between Excel and another package about quartiles that is worth\ninvestigating is on small `n`, and every one that is not is on large `n`.\n\n**Sorting and cost.** A full `O(n log n)` sort where a linear-time selection would do, and a\ntotal-order comparison that treats incomparable pairs as equal — reachable only if a NaN crosses\nin from an add-in boundary, since the worksheet value universe has none.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **Fewer than three numeric values.** `#NUM!`, for the structural reason above rather than\n  because the data is malformed. This is the edge case that surprises people: a two-point sample\n  has a perfectly good inclusive first quartile and no exclusive one.\n- **`quart` outside `{1, 2, 3}`.** `#NUM!`. In particular `QUARTILE.EXC(A, 0)` and\n  `QUARTILE.EXC(A, 4)` are errors, not the minimum and maximum.\n- **Repeated values** are ordinary; a constant data set returns that constant at every admissible\n  `quart`.\n- **Non-numeric cells in `array`** are skipped and do not enlarge `n` — which means adding a text\n  label to the top of a two-number column does not rescue it from `#NUM!`.\n- **Errors in `array`** propagate as themselves.\n- The result is an interpolated value and need not appear in the data.\n\n\n",
    "sources": "- Microsoft, *QUARTILE.EXC function* —\n  <https://support.microsoft.com/en-us/office/quartile-exc-function-5a355b7a-840b-4a01-b0f1-f538c2864cad>\n  (signature, the three admissible `quart` values, and the documented `#NUM!` conditions for an\n  empty array and an out-of-range `quart`). Retrieval was blocked by the upstream host for this\n  page; the documented behaviour above is stated as documented behaviour and should be re-checked\n  against the page.\n- R. J. Hyndman and Y. Fan, \"Sample Quantiles in Statistical Packages\", *The American\n  Statistician* 50(4), 1996, pp. 361–365 — the taxonomy, the plotting-position derivation, and\n  the identification of the exclusive convention as type 6.\n- Handbook [coercion and lifting](../model/02-coercion-and-lifting.md) — the range-scan policy\n  that decides what counts toward `n`.\n- Handbook `data/functions/FUNC.QUARTILE.EXC.json`, `data/presence/FUNC.QUARTILE.EXC.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`QUARTILE.EXC(array, quart)` returns a **sample quantile** of the data in `array` under the\n*exclusive* convention: the one that treats the sample as an interior slice of an unseen\npopulation, and therefore declines to identify any quantile with the observed extremes.\n\nSort the numeric values of `array` ascending as `x_(1) <= … <= x_(n)`, and let `k = quart/4` with\n`quart` in `{1, 2, 3}`, so `k` is `1/4`, `1/2` or `3/4`. Define the **rank**\n\n    h  =  k * (n + 1)\n\nand, writing `j = floor(h)` and `g = h - j`,\n\n    QUARTILE.EXC  =  x_(j)  +  g * ( x_(j+1) - x_(j) )\n\nThe `n + 1` is the whole difference from [QUARTILE.INC](FUNC.QUARTILE.INC.md), and it changes the\nfunction's character rather than just its answer. This is **type 6** in the Hyndman–Fan taxonomy,\nthe definition used by Minitab and by SPSS, and it comes from assigning the order statistic\n`x_(i)` the plotting position `i/(n+1)` — the expected value of the `i`-th uniform order\nstatistic. Under that assignment the sample never reaches probability `0` or `1`, because no\nfinite sample can be expected to contain the population extremes.\n\nThree consequences follow directly from the rank formula, and all three are user-visible:\n\n1. **There is no `quart = 0` and no `quart = 4`.** `k = 0` gives `h = 0` and `k = 1` gives\n   `h = n+1`, and both lie outside `[1, n]`. The minimum and maximum are simply not quantiles\n   under this convention. `QUARTILE.EXC` admits only `1`, `2`, `3`.\n2. **The function is undefined on small samples.** `h = (n+1)/4 >= 1` requires `n >= 3`. With\n   `n = 1` or `n = 2` the first quartile's rank falls below the first order statistic and the\n   result is `#NUM!` — even though the data is perfectly well formed and\n   [QUARTILE.INC](FUNC.QUARTILE.INC.md) answers happily. The mirror condition\n   `3(n+1)/4 <= n` also requires `n >= 3`.\n3. **`QUARTILE.EXC` is more extreme than `QUARTILE.INC` in both tails.** For the same data,\n   `QUARTILE.EXC(A,1) <= QUARTILE.INC(A,1)` and `QUARTILE.EXC(A,3) >= QUARTILE.INC(A,3)`, so the\n   exclusive interquartile range is the wider of the two. That is the intended behaviour: the\n   exclusive convention is making an allowance for the population beyond the sample.\n\nAt `quart = 2` the two conventions coincide. The exclusive rank is `(n+1)/2` and the inclusive\nrank is `1 + (n-1)/2`, which is the same number, so\n\n    QUARTILE.EXC(A, 2)  =  QUARTILE.INC(A, 2)  =  MEDIAN(A)\n\nfor every `n >= 3`. The median is the one quartile everybody agrees on, which is exactly why it\nis the one people report.\n\n**There is no single correct definition of a sample quartile.** Hyndman and Fan catalogue nine\nconventions in use. Excel publishes two of them under two names and lets the caller choose. A\nreader comparing Excel against R, SAS or SPSS should expect a different number, and should check\nwhich type the other tool used before calling anything wrong.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Admissible |\n|---|---|---|\n| `array` | The data set. Required. | Any range or array; numeric cells are used |\n| `quart` | Which quartile. Required. | `1, 2, 3` |\n\n`array` is consumed by scanning: text, logical values and blank cells in a scanned range are\nskipped rather than converted, so `n` is the count of *numeric* cells. See\n[coercion and lifting](../model/02-coercion-and-lifting.md).\n\n\n"
  },
  "signature": {
    "display": "QUARTILE.EXC(array, quart)",
    "parameters": [
      {
        "description": null,
        "name": "array",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "quart",
        "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": "A quartile of a data set, from percentiles with 0 and 1 excluded",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the quartile of the data set, based on percentile values from 0..1, exclusive",
        "microsoft_url": "https://support.microsoft.com/en-us/office/quartile-exc-function-5a355b7a-840b-4a01-b0f1-f538c2864cad"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "bg-BG",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "cs-CZ",
          "name": "QUARTIL.EXC"
        },
        {
          "locale": "da-DK",
          "name": "KVARTIL.UDELAD"
        },
        {
          "locale": "de-DE",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "el-GR",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "en-AU",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "en-GB",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "en-US",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "es-ES",
          "name": "CUARTIL.EXC"
        },
        {
          "locale": "et-EE",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "fi-FI",
          "name": "NELJÄNNES.ULK"
        },
        {
          "locale": "fr-FR",
          "name": "QUARTILE.EXCLURE*"
        },
        {
          "locale": "he-IL",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "hr-HR",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "hu-HU",
          "name": "KVARTILIS.KIZÁR"
        },
        {
          "locale": "id-ID",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "it-IT",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "ja-JP",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "ko-KR",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "lt-LT",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "lv-LV",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "nb-NO",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "nl-NL",
          "name": "KWARTIEL.EXC"
        },
        {
          "locale": "pl-PL",
          "name": "KWARTYL.PRZEDZ.OTW"
        },
        {
          "locale": "pt-BR",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "pt-PT",
          "name": "QUARTIL.EXC"
        },
        {
          "locale": "ro-RO",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "ru-RU",
          "name": "КВАРТИЛЬ.ИСКЛ"
        },
        {
          "locale": "sk-SK",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "sl-SI",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "sv-SE",
          "name": "KVARTIL.EXK"
        },
        {
          "locale": "th-TH",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "tr-TR",
          "name": "DÖRTTEBİRLİK.HRC"
        },
        {
          "locale": "uk-UA",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "vi-VN",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "zh-CN",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "zh-HK",
          "name": "QUARTILE.EXC"
        },
        {
          "locale": "zh-TW",
          "name": "QUARTILE.EXC"
        }
      ],
      "signature": {
        "display": "QUARTILE.EXC(array, quart)",
        "parameters": [
          {
            "description": null,
            "name": "array",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "quart",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "QUARTILE.EXC",
      "version_marker": null,
      "xlcall": {
        "code": "506",
        "symbol": "xlfQuartile_exc"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/quartile-exc-function-5a355b7a-840b-4a01-b0f1-f538c2864cad"
  },
  "try_it": {
    "formula": "=QUARTILE.EXC({1;2;3;4;5},1)"
  },
  "url": "https://handbook.dnacalc.com/functions/QUARTILE.EXC.html",
  "variants": [],
  "versions": []
}