Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


notation: RV= random variable, $\mu=$ mean $m=$ median

Jensen's Inequality considers the relationship between the mean of a function of an RV and the function of the mean of an RV.

If $f(x)$ strictly convex:

$$\mu (f(x)) > f(\mu (x))\mathrm{\hspace{20mm}(1)}$$

Conversely if -f(x) is strictly convex:

$$\mu (f(x)) < f(\mu (x))$$

An analogous property of the median has been presented (Merkle et al 2005, pdf).


I have a nonlinear function of positive random variables.

In practice, I find that the function of the medians provides a much better estimate of the median of the function than does the estimate of the mean of the function from the function of the means. I am interested in learning the conditions for which this is true.


Under what conditions will the function of a median be closer to the median of a function than the mean of a function is to a function of the mean?

Specifically for what types of $f(x)$ and $x$ is

$$\mu (f(x)) - f(\mu (x)) > m (f(x)) - f(m (x))$$

simulation results

I used an empirical approach (the one I know) to investigate this question for a function of a single variable:

Interestingly, for $x>0$,

$$m(x^2)\simeq m(x)^2$$

x<-cbind(rlnorm(100, 1), rbeta(100, 1, 5), rgamma(100,0.5,0.5))
quad <- function(x)x^2

median.x <- apply(x,2,quantile,0.5)
mean.x <- apply(x,2,mean)


apply(quad(x), 2, quantile, 0.5)

For a slightly more complicated function, my proposal (equation 1) is true

miscfn <- function(x) 1 + x + x^log(x^2) - exp(-2(x)*5^x 


apply(miscfn(x), 2, quantile, 0.5)

abs(apply(miscfn(x),2,mean)-miscfn(mean.x)) > abs(apply(miscfn(x), 2, quantile, 0.5) - miscfn(median.x))

However, before I begin to use this observation in my work, I would like to know more about its conditions.


Merkle et al 2005 Jensen's inequality for medians. Statistics & Probability Letters, Volume 71, Issue 3, 1 March 2005, Pages 277-281

share|improve this question
Thanks for the clarification and for encouraging me to read up, think a bit, and revise my question. It led me to the Merkle reference. Additional feedback appreciated. – David LeBauer Nov 18 '10 at 3:03
(+1) wow, that's great improvement. I'll delete my earlier comment. – user1108 Nov 18 '10 at 4:07
up vote 4 down vote accepted

Let the cdf of $x$ be denoted by $F_X(x)$. Thus, the median of $X$ denoted by $m_x$ satisfies:


Consider $Y = X^2$. Thus, the cdf of $Y$ is given by:

$P(Y \le y) = P(X^2 \le y)$

In other words, the cdf of $Y$ is given by:

$F_Y(y) = F_X(\sqrt{y}) - F_X(-\sqrt{y})$

The median for $Y$ denoted by $m_Y$ satisfies:


In other words, it should satisfy:

$F_X(\sqrt{m_y}) - F_X(-\sqrt{m_y}) = 0.5$

If $m_y = (m_x)^2$ then it must be that:

$F_X(m_x) - F_X(-m_x) = 0.5$

The above with the first equation suggests that the relationship $m(x^2) = m(x)^2$ will only hold if $F_X(-m_x) = 0$. Thus, the relationship holds only if the support of $X$ is positive.

The examples you examined in your code have a positive support and hence you find that $m(x^2) = m(x)^2$. If you try a uniform distribution (e.g., U(-1,1)) you will find that $m(x^2) \ne m(x)^2$

share|improve this answer
Thanks for your answer, but what I am really interested in knowing is under what cases using medians rather than means provides better estimates the central tendency (median or mean) of the function. – David LeBauer Nov 18 '10 at 17:55

It seems to me that if $f$ is strictly monotonic, $m \circ f=f \circ m$, and the question reduces to $\mu\circ f>f\circ\mu$, which is covered by Jensen's inequality. So strict convexity and strict monotonicity together would be a sufficient condition.

share|improve this answer
I changed "monotonous" (= boring) to "monotonic" (= strictly increasing or strictly decreasing). However, the second statement is not true: there are nonlinear f's that preserve the mean. For example, when the RV is symmetric, then any f for which f(x - mu) = -f(mu - x) (for all x) will preserve the mean. – whuber Nov 26 '10 at 17:34
You are right, of course. I fixed my approach. – sesqu Dec 1 '10 at 5:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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