{
  "id": "quartile",
  "version": "04450dc75b68",
  "status": "published",
  "name": "Quartile Calculator",
  "question": "What are the quartiles of my data?",
  "summary": "Computes the first, second, and third quartiles and the interquartile range of a list of numbers by a named method, with the five-number summary and outliers.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/quartile-calculator",
  "markdown": "https://www.acalculator.org/statistics/quartile-calculator.md",
  "kind": "function",
  "method": "Sort the numbers; Q2 is the median; Q1 and Q3 follow the chosen method; IQR = Q3 − Q1; outliers lie outside Q1 − 1.5 × IQR and Q3 + 1.5 × IQR.",
  "assumptions": [
    "The default method (median of halves, median left out) is the old page’s method, so old links show the same quartiles.",
    "With one number, every quartile is that number.",
    "Outliers use Tukey’s 1.5 × IQR fences; a value exactly on a fence is not an outlier."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "input": {
        "title": "Your numbers",
        "description": "The numbers, separated by commas, spaces, semicolons, or new lines.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "method": {
        "title": "Quartile method",
        "description": "How Q1 and Q3 are found. Methods agree on the median but can differ on Q1 and Q3.",
        "type": "string",
        "enum": [
          "moore-mccabe",
          "tukey",
          "inclusive",
          "exclusive"
        ]
      }
    }
  },
  "outputs": {
    "iqr": {
      "label": "Interquartile range (IQR)",
      "description": "Q3 minus Q1: the spread of the middle half of the data.",
      "format": "number"
    },
    "q1": {
      "label": "First quartile (Q1)",
      "description": "The 25th percentile by the chosen method.",
      "format": "number"
    },
    "q2": {
      "label": "Median (Q2)",
      "description": "The middle value: the 50th percentile.",
      "format": "number"
    },
    "q3": {
      "label": "Third quartile (Q3)",
      "description": "The 75th percentile by the chosen method.",
      "format": "number"
    },
    "min": {
      "label": "Minimum",
      "description": "The smallest number in the list.",
      "format": "number"
    },
    "max": {
      "label": "Maximum",
      "description": "The largest number in the list.",
      "format": "number"
    },
    "range": {
      "label": "Range",
      "description": "The maximum minus the minimum.",
      "format": "number"
    },
    "lowerFence": {
      "label": "Lower fence",
      "description": "Q1 − 1.5 × IQR. Values below it are outliers.",
      "format": "number"
    },
    "upperFence": {
      "label": "Upper fence",
      "description": "Q3 + 1.5 × IQR. Values above it are outliers.",
      "format": "number"
    },
    "outliers": {
      "label": "Outliers",
      "description": "Values below the lower fence or above the upper fence, smallest first, or None.",
      "format": "text"
    },
    "count": {
      "label": "Count",
      "description": "How many numbers are in the list.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "input": "1, 2, 3, 4, 5, 6, 7, 8, 9, 10",
      "method": "moore-mccabe"
    },
    "outputs": {
      "iqr": 5,
      "q1": 3,
      "q2": 5.5,
      "q3": 8,
      "min": 1,
      "max": 10,
      "range": 9,
      "lowerFence": -4.5,
      "upperFence": 15.5,
      "outliers": "None",
      "count": 10
    },
    "text": "With the quartile method set to Median of halves (TI-83), Q1 is 3, the median is 5.5, and Q3 is 8, so the IQR is 5."
  },
  "examples": [
    {
      "given": {
        "input": [
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10
        ],
        "method": "moore-mccabe"
      },
      "expect": {
        "q1": 3,
        "q2": 5.5,
        "q3": 8,
        "iqr": 5,
        "lowerFence": -4.5,
        "upperFence": 15.5,
        "outliers": "None"
      },
      "source": "hand calculation in content.mdx: halves 1–5 and 6–10 have medians 3 and 8; OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data (quartiles, interquartile range and outliers). https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data"
    },
    {
      "given": {
        "input": [
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10
        ],
        "method": "inclusive"
      },
      "expect": {
        "q1": 3.25,
        "q2": 5.5,
        "q3": 7.75,
        "iqr": 4.5
      },
      "source": "hand calculation in content.mdx: positions 1 + 9 × 0.25 = 3.25 and 7.75; Python statistics.quantiles(method=\"inclusive\") gives [3.25, 5.5, 7.75]; NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles (sample quantile definitions). https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm"
    },
    {
      "given": {
        "input": [
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10
        ],
        "method": "exclusive"
      },
      "expect": {
        "q1": 2.75,
        "q2": 5.5,
        "q3": 8.25,
        "iqr": 5.5
      },
      "source": "hand calculation in content.mdx: positions 11 × 0.25 = 2.75 and 8.25; Python statistics.quantiles(method=\"exclusive\") gives [2.75, 5.5, 8.25]; NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles (sample quantile definitions). https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm"
    },
    {
      "given": {
        "input": [
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9
        ],
        "method": "tukey"
      },
      "expect": {
        "q1": 3,
        "q2": 5,
        "q3": 7,
        "iqr": 4
      },
      "source": "hand calculation in content.mdx: halves 1–5 and 5–9 have medians 3 and 7; OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data (quartiles, interquartile range and outliers). https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data"
    },
    {
      "given": {
        "input": [
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9
        ],
        "method": "moore-mccabe"
      },
      "expect": {
        "q1": 2.5,
        "q2": 5,
        "q3": 7.5,
        "iqr": 5
      },
      "source": "hand calculation in content.mdx: halves 1–4 and 6–9 have medians 2.5 and 7.5; OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data (quartiles, interquartile range and outliers). https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data"
    },
    {
      "given": {
        "input": [
          10,
          20,
          30,
          40,
          50,
          60,
          70,
          80,
          90,
          1000
        ],
        "method": "moore-mccabe"
      },
      "expect": {
        "q1": 30,
        "q2": 55,
        "q3": 80,
        "iqr": 50,
        "upperFence": 155,
        "outliers": "1000"
      },
      "source": "hand calculation in content.mdx: 80 + 1.5 × 50 = 155, and 1000 is above it; OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data (quartiles, interquartile range and outliers). https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data"
    }
  ],
  "sources": [
    "OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data (quartiles, interquartile range and outliers). https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.6.2 Percentiles (sample quantile definitions). https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm"
  ],
  "related": [],
  "changelog": [
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    },
    {
      "date": "2026-10-01",
      "note": "The answer sentence reads correctly for every method name."
    }
  ]
}
