# Calculate median without access to raw data

I'm working in a piece of software designed for satellite image classification based on various features of objects in the image. The software provides various built-in features like the mean of the values in the object, the maximum and minimum of the values etc. However, I want to use the median of the values.

I don't have access to the raw values in the object, all I have is the information below:

• Mean
• Max
• Min
• Standard Deviation

And I can do arithmetic on those values using standard operators (+, -, /, *, ^ etc).

Is there a way to calculate the median (or something closely approximating it) from just this information?

## 2 Answers

The question can be construed as requesting a nonparametric estimator of the median of a sample in the form f(min, mean, max, sd). In this circumstance, by contemplating extreme (two-point) distributions, we can trivially establish that

$$2\ \text{mean} - \text{max} \le \text{median} \le 2\ \text{mean} - \text{min}.$$

There might be an improvement available by considering the constraint imposed by the known SD. To make any more progress, additional assumptions are needed. Typically, some measure of skewness is essential. (In fact, skewness can be estimated from the deviation between the mean and the median relative to the sd, so one should be able to reverse the process.)

One could, in a pinch, use these four statistics to obtain a maximum-entropy solution and use its median for the estimator. Actually, the min and max probably won't be any good, but in a satellite image there are fixed upper and lower bounds (e.g., 0 and 255 for an eight-bit image); these would constrain the maximum-entropy solution nicely.

It's worth remarking that general-purpose image processing software is capable of producing far more information than this, so it could be worthwhile looking at other software solutions. Alternatively, often one can trick the software into supplying additional information. For example, if you could divide each apparent "object" into two pieces you would have statistics for the two halves. That would provide useful information for estimating a median.

If you know underlying distribution of the data, you can.

For example, for normal distributed data, the mean and median are same (median=mode=mean).

Or for exponential distribution with mean $\lambda^{-1}$ the median is $\lambda^{-1} ln(2)$.

it is impossible to obtain median without having raw data or knowing the actual data distribution.

• I'd add that the mean, sd, max and min provide some evidence regarding the issue of whether assuming the underlying distribution is symmetric is a reasonable assumption; if the distribution is symmetric then the population mean and median will be the same. Dec 9, 2010 at 10:54
• Thank you. Unfortunately my data does not conform to any particular distribution, so I will be unable to use these methods. It is still useful information to know, so thank you anyway. Dec 9, 2010 at 14:50
• @robintw: If you guess the data does not fit to any particular distribution, the Normal distribution may be the best choice, especially if the values are mixture of several other values (Look at en.wikipedia.org/wiki/Central_limit_theorem ) Dec 9, 2010 at 15:02
• @Isaac The CLT is irrelevant and inapplicable: we seek the median of the parent distribution, not the median of the sampling distribution of the mean. However, it (coincidentally) turns out that the maximum entropy solution (given the mean, sd, and upper and lower bounds for all values) is a doubly truncated Gaussian distribution. One would numerically solve for its parameters to match the observed mean and sd and then compute its median (which will usually not be the same as its mean because the truncation can be asymmetric).
– whuber
Dec 9, 2010 at 20:52
• @Jeromy The only statistic that can be formed of those four values that provides any information about symmetry is the ratio (max - mean):(mean - min). That's a (highly) non-robust statistic, though: I would entirely discount its use in a practical problem. However, when data are constrained to lie between two limits, those limits (relative to the mean) do add useful information.
– whuber
Dec 9, 2010 at 20:56