{
  "id": "percentile",
  "version": "6a3295255d1e",
  "status": "published",
  "name": "Percentile Calculator",
  "question": "What is the percentile?",
  "summary": "Computes the value at any percentile of a list of numbers, by the NIST, Excel inclusive, or nearest-rank method, and the percentile rank of a value.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/percentile-calculator",
  "markdown": "https://www.acalculator.org/statistics/percentile-calculator.md",
  "kind": "function",
  "method": "Sort the N numbers. Position = (N + 1)p (NIST), 1 + (N − 1)p (Excel inclusive), or ⌈Np⌉ (nearest rank); value = x[k] + d × (x[k + 1] − x[k]) for position k + d. Percentile rank of x = (B + 0.5E) ÷ N × 100.",
  "assumptions": [
    "Positions below 1 give the smallest number, and positions at or above N give the largest (NIST §7.2.6.2).",
    "In the percentile rank, B counts the numbers below the value and E the numbers equal to it.",
    "The arithmetic is exact on the decimals you type, then rounded once for display."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "data": {
        "title": "Your numbers",
        "description": "The numbers, separated by commas, spaces, semicolons, or new lines.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "p": {
        "title": "Find the value at percentile",
        "description": "The percentile to find, from 0 to 100: 90 for the 90th percentile. Leave empty to skip.",
        "type": "number",
        "minimum": 0,
        "maximum": 100
      },
      "method": {
        "title": "Percentile method",
        "description": "How the position in the sorted list is found: (N + 1)p as in the NIST handbook, 1 + (N − 1)p as in Excel’s PERCENTILE.INC, or the nearest rank ⌈Np⌉.",
        "type": "string",
        "enum": [
          "nist",
          "excel",
          "nearest"
        ]
      },
      "x": {
        "title": "Find the percentile of value",
        "description": "A value whose percentile rank in your numbers you want. Leave empty to skip.",
        "type": "number"
      }
    }
  },
  "outputs": {
    "value": {
      "label": "Value at the percentile",
      "description": "The value at the chosen percentile of your numbers, by the chosen method.",
      "format": "number"
    },
    "position": {
      "label": "Position in the sorted list",
      "description": "Where the percentile falls in the sorted list, counting from 1; a fraction means between two numbers.",
      "format": "number"
    },
    "rank": {
      "label": "Percentile rank of the value",
      "description": "The percent of your numbers below the value, counting numbers equal to it as half: (B + 0.5E) ÷ N × 100.",
      "format": "number"
    },
    "below": {
      "label": "Percent below the value",
      "description": "The percent of your numbers that are less than the value.",
      "format": "percent"
    },
    "atOrBelow": {
      "label": "Percent at or below the value",
      "description": "The percent of your numbers that are less than or equal to the value.",
      "format": "percent"
    },
    "count": {
      "label": "Count (N)",
      "description": "How many numbers are in the list.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "data": "12, 15, 18, 20, 22, 25, 28, 30, 35, 40",
      "p": 90,
      "method": "nist",
      "x": 25
    },
    "outputs": {
      "value": 39.5,
      "position": 9.9,
      "rank": 55,
      "below": 50,
      "atOrBelow": 60,
      "count": 10
    },
    "text": "Percentile 90 of your 10 numbers is 39.5, and the value 25 is at percentile rank 55."
  },
  "examples": [
    {
      "given": {
        "data": [
          95.1772,
          95.1567,
          95.1937,
          95.1959,
          95.1442,
          95.061,
          95.1591,
          95.1195,
          95.1065,
          95.0925,
          95.199,
          95.1682
        ],
        "p": 90,
        "method": "nist"
      },
      "expect": {
        "value": 95.19807,
        "position": 11.7
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles. https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm (95.1981)"
    },
    {
      "given": {
        "data": [
          95.1772,
          95.1567,
          95.1937,
          95.1959,
          95.1442,
          95.061,
          95.1591,
          95.1195,
          95.1065,
          95.0925,
          95.199,
          95.1682
        ],
        "p": 90,
        "method": "excel"
      },
      "expect": {
        "value": 95.19568,
        "position": 10.9
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles. https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm (95.1957 for the Excel definition)"
    },
    {
      "given": {
        "data": [
          18,
          21,
          22,
          25,
          26,
          27,
          29,
          30,
          31,
          33,
          36,
          37,
          41,
          42,
          47,
          52,
          55,
          57,
          58,
          62,
          64,
          67,
          69,
          71,
          72,
          73,
          74,
          76,
          77
        ],
        "p": 70,
        "method": "nist",
        "x": 58
      },
      "expect": {
        "value": 64,
        "position": 21,
        "rank": 63.793103448275865,
        "below": 62.06896551724138,
        "atOrBelow": 65.51724137931035
      },
      "source": "OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data. https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data (70th percentile 64; 58 is at (18 + 0.5) ÷ 29 × 100 = 63.80)"
    },
    {
      "given": {
        "data": [
          12,
          15,
          18,
          20,
          22,
          25,
          28,
          30,
          35,
          40
        ],
        "p": 90,
        "method": "nist",
        "x": 25
      },
      "expect": {
        "value": 39.5,
        "position": 9.9,
        "rank": 55,
        "below": 50,
        "atOrBelow": 60
      },
      "source": "hand calculation in content.mdx: 0.9 × 11 = 9.9, 35 + 0.9 × 5 = 39.5; NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles. https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm"
    },
    {
      "given": {
        "data": [
          12,
          15,
          18,
          20,
          22,
          25,
          28,
          30,
          35,
          40
        ],
        "p": 90,
        "method": "nearest"
      },
      "expect": {
        "value": 35,
        "position": 9
      },
      "source": "hand calculation in content.mdx: ⌈9⌉ = 9; NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles. https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm"
    },
    {
      "given": {
        "data": [
          12,
          15,
          18,
          20,
          22,
          25,
          28,
          30,
          35,
          40
        ],
        "p": 95,
        "method": "nist"
      },
      "expect": {
        "value": 40,
        "position": 10.45
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles. https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm (for k ≥ N, the largest value)"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles. https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm",
    "OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data (percentile of a value). https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data",
    "Hyndman and Fan, Sample Quantiles in Statistical Packages, The American Statistician, 1996 (definitions 6 and 7). https://doi.org/10.1080/00031305.1996.10473566"
  ],
  "related": [
    "quartile",
    "statistics",
    "z-score",
    "mean-median-mode"
  ],
  "changelog": []
}
