Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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

I am working on a optimization-related research problem and need to know if the variance of a convex function is convex. I know this can be a little vague so I'm including a (rather formal) explanation below.

Say I have a function $v_i(x)$ where $v_i: \mathbb{R}^n \rightarrow \mathbb{R}$.

Assume that for each $i = 1...s$ the function $v_i$ can be a different convex function. Also, assume that the function has the form $v_i$ with probability $p_i$ where $\sum_{i=1}^{s}{p_i} = 1$.

Define the *expectation function as:

$E[v(x)] = \sum_{i=1}^{s}{p_i v_i(x)}$

And the *variance function as:

$Var[v(x)] = \sum_{i=1}^{s}{p_i (v_i(x) - E[v(x)])^2}$

Assume the function $v_i$ is convex for all $i = 1...s$, then:

  • Is the expectation function convex? (yes, right?)
  • Is the variance function convex? (unsure)

Also, if $v_i$ is affine for all $i = 1...s$, then:

  • Is the expectation function convex? (yes, right?)
  • Is the variance function of convex? (if not, then what is it?)
share|cite|improve this question
up vote 5 down vote accepted

First, I think your notation is bad. After taking expectation/variance, there should be no $i$ dependence. Also, your variance equation has one of the open parenthesis at a wrong place. It should be $$Var[v(x)] = \sum_{i=1}^{s}{p_i*(v_i(x) - E[v(x)])^2}.$$

Anyway, the expectation, as a linear combination of convex functions, is definitely convex. But the variance is not. For example, take $s=2, p_1=p_2=1/2, v_1(x)=x^2, v_2(x)=x^4$, then the "variance" would be a polynomial $\frac{x^4}4(1-2x^2+x^4)$ which is nonnegative (of course) but not convex.

If all the $v_i$ are linear functions, then so is the expectation, hence convex. In this case, the variance is also convex, because it's a linear combination of convex functions $(v_i(x) - E[v(x)])^2$. (Note that each $(v_i(x) - E[v(x)])^2$ is convex because it's the square of a linear function.)

share|cite|improve this answer
Thank you! One last question: in the case of linear functions, how do you know that the square of a linear function is convex? – Elements Apr 20 '11 at 8:05
A linear combination of convex functions is not, in general, convex. You need an additional condition (which you have in this case!). – cardinal Apr 20 '11 at 12:42
@cardinal Yes, you are right. Thank you for pointing it out. If some of the scalars are negative, there might be problems. But here everything is nonnegative. – GWu Apr 20 '11 at 14:30

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.