Probability – What Is the Median of a Bernoulli Distribution?

medianprobabilityself-study

By definition of median, i.e.

$P(X\leq m)\geq 1/2 \text{ and } P(X\geq m)\geq 1/2.$

What is the median of Bernoulli distribution with a probability parameter of $p=0.2$ ($P(X=1)=0.2$)?

Suppose $m$ is the median. Then $P(X\leq m)\geq 1/2$ implies $m\geq0$. $P(X\geq m)\geq 1/2$ implies $m<0$. One says m is greater or equal to 0 and the other says it is strictly less than 0. I don't understand where I did wrong.

Here are the CDF plotenter image description here.

Best Answer

Let $X \sim \mathsf{Bern}(p=.2)\equiv\mathsf{Binom}(n=1, p=.2).$ In R, where qbinom is the inverse CDF (quantile function) of a binomial distribution a median $\eta = 0.$

qbinom(.5, 1, .2)
[1] 0

$P(X \le 0) = P(X = 0) = 0.8 \ge 1/2.$

dbinom(0, 1, .2)
[1] 0.8

And obviously, $P(X \ge 0) = 1 \ge 1/2.$

The CDF of $X$ is plotted below. The median of $X$ is taken to be the value at which the CDF 'curve' is (or 'crosses') $1/2.$

curve(pbinom(x, 1, .2), -.5, 1.5, n=10001, xaxs="i", ylab="CDF")
 k = 0:1; cdf = pbinom(k, 1, .2)
 points(k,cdf,pch=19)
 abline(h = .5, col="blue", lwd=2, lty="dotted")

enter image description here

Also, for context, if we simulate $1000$ observations from this distribution, we get $805$ Failures (0) and $195$ Successes. According to R, the sample median is also $0.$

set.seed(2020)
x = rbinom(1000, 1, .2)
table(x)
x
  0   1 
805 195 
summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  0.000   0.000   0.000   0.195   0.000   1.000