2
$\begingroup$

Median of one number = the number itself.

I am calculating the median price sq ft of properties of different areas based on the different data entries I have got that include their ID, area and price sqft.

Example, -

SNO, AREA, PRICE SQFT

1, 1, 100

2, 1, 150

3, 1, 170

4, 1, 150

5, 2, 50

I understand that mathematically median price sqft for AREA 2 = 50. But I am trying to understand that is a single entry for AREA 2 enough to generalize and find the median of entire area?

What is the minimum number of entries required for median to start making sense? I do realize that will depend upon the requirement and the situation but there has to be a general sense to it. Thanks for your help.

$\endgroup$
2
  • 1
    $\begingroup$ What is the data? How it was obtained? Why do you have only single datapoint? $\endgroup$
    – Tim
    Commented Feb 3, 2016 at 9:24
  • $\begingroup$ User enters this data when interacting with a website. He posts his area and price sqft. Apparently, only one user from AREA 2 interacted with the site. $\endgroup$ Commented Feb 3, 2016 at 9:27

1 Answer 1

5
$\begingroup$

Median may be more robust than mean, but this does not make it robust for such extreme cases like sample consisting of single datapoint.

Let's get more general for a moment, $p$ quantile ($p=0.5$ for median) of distribution is the value $m$ such that

$$ \Pr(X \leq m) = p $$

Sample quantiles are estimated using ordered sample

$$ x_1 \le x_2 \le \dots \le x_n $$

where median is the middle value of such sample (there are different ways how to define it precisely, see Hyndman and Fan, 1996). For sample of size one median can be defined as the data point, but notice that the same point is also the minimal $x_1$ and maximal value $x_n$ of this sample, so it does not tell us much.

With larger sample size you could estimate confidence intervals for median to have better understanding of uncertainty of the estimate. However the intervals are also defined in terms of order statistics, so this won't be helpful. What you can do with single value is to compute confidence intervals for mean, e.g. $95\%$ interval would be

$$ x \pm 9.68 |x| $$

As you can see, the intervals are pretty wide. We cannot get narrower intervals since the sample size is extremely small, what leads to greater uncertainty about the mean. If you can make distributional assumptions, you could try to get more precise intervals. If you have a priori knowledge about your problem you could try Bayesian approach with informative priors.

Regarding your question about sample size for estimating median, it can be easily calculated. If you think of this problem the other way around, we want $np$ out of $n$ values of $X$ be smaller or equal than $m$. If we define new random variable in terms of counts $Y = \sum_{i=1}^n [x_i \le m ]$, then it follows binomial distribution with parameters $n$ and $p$. Wald confidence interval for $p$ can be easily calculated as

$$ p \pm z_{\alpha/2} \sqrt{p(1-p)/n} $$

(but see here, here, and Brown, Cai and DasGupta, 2001). The interval can be used to find such value of $n$ that would make the interval acceptably narrow. The interval would tell us if $p$ is close enough to $0.5$ (that it is really a median). This approach can be validated using simulation.

set.seed(123)
R <- 1e5
n <- c(1, 5, 10, 15, 25, 50, 100, 250, 500, 1000)
res <- matrix(NA, R, length(n))

for (i in 1:R) {
  for (j in seq_along(n)) {
    m <- median(rnorm(n[j])) # sample median
    res[i, j] <- pnorm(m)    # population Pr(X <= m)
  }
}

wald <- function(n, p=0.5) matrix(c(-1, 1), ncol = 1) %*% (1.96 * sqrt(p*(1-p)/n)) + p

For very small sample sizes Wald intervals are wider than necessary, but for $n>10$ it yields precise estimates:

> wald(n)
      [,1]   [,2] [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10]
[1,] -0.48 0.0617 0.19 0.247 0.304 0.361 0.402 0.438 0.456 0.469
[2,]  1.48 0.9383 0.81 0.753 0.696 0.639 0.598 0.562 0.544 0.531
> apply(res, 2, quantile, c(0.025, 0.975))
        [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10]
2.5%  0.0258 0.146 0.233 0.266 0.313 0.366 0.403 0.438 0.456 0.469
97.5% 0.9745 0.853 0.769 0.733 0.687 0.635 0.596 0.562 0.544 0.531

As you can see, if $n=1$ then sample median could be possibly any value of $X$, as sample grows, sample median approaches population median, where it is for you to decide if it is precise enough.

Notice that for $n=1$ Wald's method yields improper values that fall beyond the $[0,1]$ interval for $p$ and because of that Wald's method should be used for samples of at least five.

You can also approach this problem differently if you notice that under uniform prior $p$ follows $\mathrm{Beta}(n/2+1, n/2+1)$ distribution (Pires and Amado, 2008, see also here). Knowing this, you can find such $n$ that maximizes probability of $p$ being within $\pm \varepsilon$ of $0.5$, i.e. that $ \Pr(X \le m) \geq p-\varepsilon $ and $ \Pr(X \le m) \leq p+\varepsilon $.

betapr <- function(n, eps) diff(pbeta(c(0.5-eps, 0.5+eps), n/2+1, n/2+1))
betapr <- Vectorize(betapr, "n")

That for $\varepsilon = 0.05$ returns

> betapr(n, eps = 0.05)
 [1] 0.1271114 0.2020283 0.2662452 0.3162281 0.3942332 0.5281417 0.6875108 0.8881346 0.9752351 0.9984892

So with small sample probability that $p$ is anywhere close to $0.5$ is quite small. Beta distribution can be also used for obtaining exact confidence intervals.


Hyndman, R. J., & Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361-365.

Brown, L. D., Cai, T. T., & DasGupta, A. (2001). Interval estimation for a binomial proportion. Statistical science, 101-117.

Pires, A. M., & Amado, C. (2008). Interval estimators for a binomial proportion: Comparison of twenty methods. REVSTAT‒Statistical Journal, 6(2), 165-197.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.