The probability of a randomly sampled value falling above the median is, by definition, 0.5, because the median is the 50% percentile of the values. Then the probability of both values being above the median in an indpendent sample of 2 observations is the product of the individual probabilities, or \(0.5*0.5 = 0.25\), and the probability of all 5 observations in a sample being larger than the median is \(0.5^{5}\).

Using these basic probability facts a confidence interval can be created for a sample from any distribution using the minimum and the maximum of the sample as the limits for the confidence interval. For samples of 5, the probability of all 5 observations being larger than the population median is \(0.5^{5}=0.03125\), and the probability of all 5 observations being smaller than the population median would also be \(0.5^{5}=0.03125\), so the probability that the median is outside of the range of the observations is the sum of those two probabilities, \(0.5^{5}+0.5^{5}=0.0625\). The probability that the population median is inside of the range of the sample observations is then \(1-0.0625=0.9375\). Since the the probability of the median being inside the range of observed values for samples of size 5 is 0.9375, the endpoints of the sample provide a 93.75% confidence interval for the median.

This confidence interval does not make any distributional assumptions, so it works for any sample.

The table below shows the confidence levels for confidence intervals for the median based on the minimum and maximum of samples of different sizes.

data.frame('Sample size' = 2:10, 'Confidence level' = round(1 - 2 * .5^(2:10), 4))
##   Sample.size Confidence.level
## 1           2           0.5000
## 2           3           0.7500
## 3           4           0.8750
## 4           5           0.9375
## 5           6           0.9688
## 6           7           0.9844
## 7           8           0.9922
## 8           9           0.9961
## 9          10           0.9980

The simulation below shows the actual coverage for confidence intervals constructed this way. The result here should be at least as large as the confidence level for the associatied sample size (here, n) in the previous table.

n <- 5 # sample size
myMean <- 0
mySD <- 1
nReps <- 100000
y <- rep(NA, nReps)
z <- rep(NA, nReps)
for(i in 1:nReps){
  x <- rnorm(n, myMean, mySD)
  y[i] <- min(x)
  z[i] <- max(x)
}
1 - sum(myMean < y | myMean > z) / nReps # coverage of the interval
## [1] 0.93815