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$$
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$$
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.
$$\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.