l was working with these data:


I needed to calculate the median so decided to calculate while the data was log transformed and I would just back transform for the median of the original data.

However, this wasn't the case for this dataset: the log transformed median is 5.421747, which back transforms to 226.2742, while the median of the original data is 240.

I had to do this to 30-odd datasets and it only happened in this one. I know that I am getting something wrong when adding the two mid-points and dividing by 2.

  • $\begingroup$ The transformation you used is logarithmic, and not itself called lognormal. This issue depends only on using logarithmic transformation and is nothing to do with whether the data are, or are approximately, lognormal. I've edited out a reference to lognormal transformation as if it were a typo but left your title mentioning lognormal data unchanged. $\endgroup$
    – Nick Cox
    Dec 7, 2020 at 9:27
  • $\begingroup$ Your method would work with an odd number of terms, and almost work with an even number of terms where the middle two were close together. But that is not the case here $\endgroup$
    – Henry
    Dec 7, 2020 at 15:03

1 Answer 1


In principle, median(log()) yields the same as log(median()). As @Henry rightly comments, there is no issue here with any sample with an odd number of values, as the median is then the middlemost value and its logarithm is both the median of the logarithms and the logarithm of the median on the original scale.

In practice, the issue may arise if you have an even number of values. You have here $6$ values of $160$ and $6$ of $320$ and hence an even number of values. So, you're using (or your software is using) the arithmetic mean of the two co-medians (*), here $160$ and $320$, as a conventional rule for the median of an even number of values.

For consistency with working on logarithmic scale you would need to use the geometric mean of the co-medians, namely here $\root \of {160 \times 320}$, which is indeed $226.2742$ to the same number of decimal places as in your question.

Let's suppose that you have an even number of values, so that after sorting the median is to be calculated from the co-medians $x_{(n/2)}$ and $x_{(n/2 + 1)}$. Then you won't notice a difference between arithmetic and geometric means if those two values are identical, but you should notice a difference otherwise.

(*) Co-medians as a term for the two middle values in a sample with an even number of values was an independent suggestion of Stephen M. Stigler and Roger Koenker.

  • $\begingroup$ Thanks Nick, that makes sense to me, appreciate your help $\endgroup$
    – Mick
    Dec 7, 2020 at 23:13
  • $\begingroup$ Is the issue with taking the mean of the middle two numbers related to Jensen’s inequality? $\endgroup$
    – Dave
    Dec 8, 2020 at 11:38
  • $\begingroup$ You can mention Jensen’s inequality or the AGM inequality here, but I guess people who know about either or both already wouldn’t be asking this question. $\endgroup$
    – Nick Cox
    Dec 8, 2020 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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