4

How can I prove the following function is convex? Is variance concave or convex?

$$\psi (x)=\left(x_1-\frac{x_1+x_2+x_3}{3}\right)^2+ \left(x_2-\frac{x_1+x_2+x_3}{3}\right)^2+ \left(x_3-\frac{x_1+x_2+x_3}{3}\right)^2$$

Rezlen
  • 41

2 Answers2

5

The simplest way to see that this is convex is to note that it is the composition of a trivial quadratic function and an affine function (actually a linear one); that is, $\psi(x)=g(h(x))$, where $$g:\mathbb{R}^3\rightarrow\mathbb{R}, \quad g(y) = y_1^2+y_2^2+y_3^3$$ $$h:\mathbb{R}^3\rightarrow\mathbb{R}^3, \quad h(x)=(x_1-(x_1+x_2+x_3)/3,x_2-(x_1+x_2+x_3)/3,x_3-(x_1+x_2+x_3)/3)$$ It is of course easy to verify that $g$ is convex; its Hessian is twice the identity matrix. It truly is the prototypical multivariate convex function! And the composition of a convex function and an affine function is always convex.

EDIT: This is readily extended to all data sizes. That is, the function $$\psi(x) = \sum_{i=1}^n \left( x_i - \left( \textstyle \tfrac{1}{n} \sum_{j=1}^n x_j \right)\right)^2$$ is convex for any $n$. It is the composition of the trivially convex function $$g:\mathbb{R}^n\rightarrow\mathbb{R}, \quad g(y) = \sum_{i=1}^n y_i^2$$ and the affine function $$h:\mathbb{R}^n\rightarrow\mathbb{R}^n, \quad h(x) = (h_1(x),h_2(x),\dots,h_n(x)), \quad h_i(x) = x_i - \tfrac{1}{n}\textstyle\sum_{j=1}^n x_j$$ As the composition of a convex function and an affine function, it is convex. If you are getting an indefinite Hessian for $n>3$, as you suggest you are below, then your derivation is incorrect.

Michael Grant
  • 20,110
  • @ Michael thanks , I will check the derivation! – Rezlen Dec 11 '15 at 17:46
  • @Rezlen off the top of my head I think the Hessian is $2I-\tfrac{1}{n}\vec{1}\vec{1}^T$, but don't quote me on that---unless it is right, of course, in which case, quote away! :-) – Michael Grant Dec 11 '15 at 17:47
  • you are right! My derivation was not correct! I used matlab and for any $n$ determinants are equal to zero; this is, it is semidefinite so convex! – Rezlen Dec 11 '15 at 18:58
2

$$\frac{\partial}{\partial x_1}ψ(x)=\frac23(2x_1-x_2-x_3)$$ and therefore $\frac{\partial^2}{\partial x_1^2}ψ(x)=\frac43, \frac{\partial}{\partial x_1x_2}ψ(x)=-\frac23, \frac{\partial}{\partial x_1x_3}ψ(x)=-\frac23$. So, due to symmetry the Hessian matrix is given by $$H=\begin{pmatrix}\frac{\partial}{\partial x_ix_j}ψ(x)\end{pmatrix}_{i,j}=\begin{pmatrix} \frac43&\frac{-2}3&\frac{-2}3\\ \frac{-2}3&\frac43&\frac{-2}3\\ \frac{-2}3&\frac{-2}3&\frac43\\ \end{pmatrix}=\frac23\begin{pmatrix} 2&-1&-1\\ -1&2&-1\\ -1&-1&2\\ \end{pmatrix}$$ which can be shown to be positive semidefinite (all leading principles are non-negative). So $ψ$ is convex.

Jimmy R.
  • 36,148
  • Thanks @Stef ! In fact the function is $\psi (x)=min \sum _{i=1}^{n}(f_i(x_i)-\overline f(x))^2$ – Rezlen Dec 11 '15 at 13:49
  • That's not a function, @Rezlen, that's an optimization problem. – Michael Grant Dec 11 '15 at 14:50
  • @Stef and Michael , for $n>3$ the leading principle minors are not always positive. The 1st and 2nd are positive the 3rd is zero and the 4th is negative. Could you please help me to expand it for $n$ variables? And can I say the problem is positive semidefinite in this case? – Rezlen Dec 11 '15 at 16:23
  • @stef the leading principle minores for $n>3$ are negative. How can I prove it is a semidefinite ? – Rezlen Dec 11 '15 at 16:34
  • @Rezlen I am referring to your question, which is about $n=3$. $n>3$ is another question, do not ask it here in the comments. – Jimmy R. Dec 11 '15 at 16:39
  • @Stef thank you, can I add another quesition for $n>3$ here or should be a seperate quesition? – Rezlen Dec 11 '15 at 16:43
  • @Rezlen Your welcome. A separate question is the way to go :) – Jimmy R. Dec 11 '15 at 17:12
  • @Rezlen, variance is always convex in the data. If you're seeing something different for $n>3$ then your derivation is somehow wrong. – Michael Grant Dec 11 '15 at 17:21