Skip to main content
v2026.11,858 entries · CC-BY 4.0

Median of a Binomial Distribution: Formula, Rule and Worked Example

How to find the median of a binomial distribution: the floor(np)/ceil(np) rule, worked examples, non-unique cases, APA wording and Excel, R and Python code.

Written and maintained by CASRAI Editorial Board

Last updated

The median of a binomial distribution is the smallest whole number m for which the cumulative probability P(X ≤ m) reaches 0.5. There is no single closed-form formula, but the answer is always floor(np) or ceil(np), and in most practical cases it is simply np rounded to the nearest integer. This guide shows the rule, the arithmetic behind it with worked numbers, and when the answer is not unique.

Definition in one paragraph

For a binomial random variable X (the number of successes in n independent trials, each with success probability p), a median is any value m such that P(X ≤ m) ≥ 0.5 and P(X ≥ m) ≥ 0.5. Because X only takes whole-number values, the cumulative distribution function jumps in steps, so the median is found by accumulating probabilities until the running total first reaches 0.5. Software almost always reports the smallest such value. For the underlying ideas see the cumulative distribution function and the probability mass function.

Is there a formula for the median of a binomial distribution?

Not a single exact one. What exists is a pair of rules that pin the median down to at most two candidate integers:

  • Bounds: every median m satisfies floor(np) ≤ m ≤ ceil(np) (a result usually credited to Kaas and Buhrman, 1980).
  • Integer mean: if np is a whole number, then mean = median = mode = np (Kaas and Buhrman, 1980, abstract).
  • Rounding rule: when |m − np| ≤ min(p, 1 − p), the median is unique and equals np rounded to the nearest integer (also credited to Kaas and Buhrman). The case p = 0.5 with odd n is the exception (see below). For rational p, Nowakowski shows that p = 0.5 with odd n is the only case where the median is not unique.

The pmf behind all of this is f(k) = C(n, k) pk (1 − p)n−k for k = 0, 1, …, n, with 0 ≤ p ≤ 1 (the form used in the SciPy documentation). Symbols: n is the number of trials, p the success probability, k a possible count of successes, C(n, k) the number of ways to choose k successes from n trials, and np the mean. The mean itself is covered in the binomial expected value guide.

Median of binomial distribution: floor(np) or ceil(np)

The median is never further from np than the next whole number on either side. If np is 4.2, the median is 4 or 5; the cumulative sum decides which. If np is exactly 3, the median is 3 and no sum is needed.

Worked example 1: n = 10, p = 0.25 (np = 2.5)

Accumulate the pmf until the running total first reaches 0.5.

  • P(X = 0) = 0.7510 = 0.056314; running total 0.056314
  • P(X = 1) = 10 × 0.25 × 0.759 = 0.187712; running total 0.244025
  • P(X = 2) = 45 × 0.252 × 0.758 = 0.281568; running total 0.525593

The total first passes 0.5 at k = 2, so the median is 2. Here np = 2.5 sits exactly halfway between 2 and 3, and floor(np) = 2 is the answer. Rounding 2.5 would give 3 under a round-half-up convention, which is wrong here: the rounding rule only applies when |m − np| ≤ min(p, 1 − p), and 0.5 is larger than min(0.25, 0.75) = 0.25.

Worked example 2: n = 7, p = 0.5 (a whole interval of medians)

For p = 0.5 every pmf value is C(7, k)/128, giving 1, 7, 21, 35, 35, 21, 7, 1 over 128.

  • k = 0: total 1/128 = 0.0078
  • k = 1: total 8/128 = 0.0625
  • k = 2: total 29/128 = 0.2266
  • k = 3: total 64/128 = 0.5 exactly

F(3) = 0.5 and P(X ≥ 4) = 0.5, so every value from 3 to 4 satisfies the definition. The smallest median is 3, which is what R and SciPy return. With p = 1/2 and n even the median is unique at n/2; with n odd, any value in [(n − 1)/2, (n + 1)/2] qualifies.

Worked example 3: n = 5, p = 0.1 (rounding fails)

P(X = 0) = 0.95 = 0.59049, already above 0.5, so the median is 0 although np = 0.5. The result still sits inside the bounds floor(0.5) = 0 and ceil(0.5) = 1.

Median vs mean vs mode of a binomial

Kaas and Buhrman (1980) note that the ordering mean-median-mode that holds for some continuous distributions does not hold in general for binomials; when median and mode differ, the mean lies between them. Computed from the pmf:

n p Mean np Median (smallest) Mode
10 0.30 3 3 3
10 0.25 2.5 2 2
12 0.35 4.2 4 4
7 0.50 3.5 3 (3 and 4 both valid) 3 and 4
5 0.10 0.5 0 0

When is the binomial median equal to the mean?

When np is a whole number. In the first row of the table, 10 × 0.3 = 3, and mean, median and mode all equal 3.

Interpretation: reading the result

Situation What it means for the median
np is a whole number Median = np; no accumulation needed
np not whole, p far from 0.5 Median is floor(np) or ceil(np); check by accumulating the pmf
p = 0.5, n even Unique median n/2
p = 0.5, n odd Any value in [(n − 1)/2, (n + 1)/2]; report the smallest by convention

A median of m says that at least half the probability lies at or below m and at least half at or above it. For heavily skewed cases (small p, small n) the median can sit well below what the mean suggests; see skewness.

Assumptions and common mistakes

  • The formula assumes a fixed n, independent trials and a constant p. If p varies between trials the count is not binomial.
  • Do not use np rounded as a guaranteed answer. Example 1 and example 3 show cases where the half-way or small-np value must be settled by the cumulative sum.
  • Do not assume the median is unique when p = 0.5 and n is odd.
  • Do not use the normal approximation to name an exact median for small n; compute from the pmf.

How to report it (APA example)

State the convention, because the median is not unique in some cases. Example wording: The number of responders followed a binomial distribution with n = 10 and p = .25; the median was 2 (the smallest value with a cumulative probability of at least .50, F(2) = .526). For a case like example 2: The median was 3 (the smallest value with F(m) ≥ .50; F(3) = .50 exactly, so 3 and 4 are both medians).

Binomial median in Excel, R and Python

Each of these returns the smallest value whose cumulative probability is at least the requested level.

Excel: =BINOM.INV(10, 0.25, 0.5) returns 2. Microsoft documents BINOM.INV as returning “the smallest value for which the cumulative binomial distribution is greater than or equal to a criterion value.” To see the working, list k in one column and =BINOM.DIST(A2, 10, 0.25, TRUE) in the next.

R: qbinom(0.5, size = 10, prob = 0.25) returns 2. The R documentation defines the quantile as “the smallest value x such that F(x) >= p”.

Python (SciPy):

from scipy.stats import binom
binom.median(10, 0.25)    # 2.0
binom.ppf(0.5, 10, 0.25)  # 2.0 (inverse of the cdf)
binom.cdf(2, 10, 0.25)    # 0.5255928...

If you want to check a result by hand without code, the binomial probability calculator guide explains the individual terms.

FAQ

Is the median of a binomial distribution always an integer?

The smallest median is always an integer. When p = 0.5 and n is odd, every real number between (n − 1)/2 and (n + 1)/2 also satisfies the definition, though the integer is what software reports.

Is the median the same as np?

Only when np is a whole number. Otherwise the median is floor(np) or ceil(np).

Which function gives the median in software?

Excel BINOM.INV with a criterion of 0.5, R qbinom(0.5, n, p), and SciPy binom.median(n, p) or binom.ppf(0.5, n, p).

Sources

Checked 2026-10-29.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Median of a Binomial Distribution: Formula, Rule and Worked Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.