CVXOPT HW4
$\newcommand{\R}{\mathbb{R}}$
1) Consider the Support Vector Machine primal optimization problem from class. Here we have data $x_i \in \R^d$ with corresponding labels $y_i \in \{-1, 1\}$, for $i = 1,\ldots, N$. The goal is to find a weight vector $w\in\R^d$ and $b\in\R$. The $\zeta_i$ are slack variables.
$$ \begin{align*} \text{minimize}\quad&\frac{1}{2}\|w\|_2^2 + C \sum_i \zeta_i\\ \text{subject to}\quad&y_i(w^Tx_i + b) \ge 1 - \zeta_i\quad i=1, \ldots, N\\ &\zeta \succeq 0 \end{align*} $$Derive the dual optimization problem
Converting this to standard optimization problem form
$$ \begin{align*} \text{minimize}\quad & \frac{1}{2}\|w\|_2^2 + C \sum_i \zeta_i\\ \text{subject to}\quad & 1 - y_i (w^T x_i - b) - \zeta_i \le 0\quad i=1, \ldots, N\\ & -\zeta \preceq 0 \end{align*} $$We have a function in $w, \zeta$ that we want to minimize with $2N$ constraints.
Lagrangian is
$$ \begin{align*} \mathcal{L}(w, b, \lambda, \zeta) &= \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N \lambda_i (1 - y_i (w^T x_i - b) - \zeta_i) - \sum_i^N \lambda_{2i}\zeta_i \\ &= \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N( \lambda_i - \lambda_i y_i (w^T x_i - b) - \lambda_i\zeta_i) - \sum_i^N \lambda_{2i}\zeta_i\\ &= \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N( \lambda_i - \lambda_i y_i w^T x_i +\lambda_i y_i b - \lambda_i\zeta_i) - \sum_i^N \lambda_{2i}\zeta_i\\ &= \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i + \sum_{i}^N \lambda_i y_i b -\sum_{i}^N \lambda_i\zeta_i - \sum_i^N \lambda_{2i}\zeta_i\\ &= \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i + b\sum_{i}^N \lambda_i y_i -\sum_{i}^N \lambda_i\zeta_i - \sum_i^N \lambda_{2i}\zeta_i\\ &= \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i + b\sum_{i}^N \lambda_i y_i -\sum_{i}^N (\lambda_i -\lambda_{2i})\zeta_i\\ \end{align*} $$Differentiating with respect to $w$
$$ \nabla_w \mathcal{L} = w - \sum_i \lambda_i y_i x_i $$Setting it to be zero
$$ 0 = w - \sum_i \lambda_i y_i x_i\\ \boxed{w = \sum_i \lambda_i y_i x_i}\\ $$Differentiating with respect $b$
$$ \frac{d \mathcal{L}}{db} = \sum_i^N y_i \lambda_i $$Setting it to be 0
$$ \boxed{\sum_i \lambda_i y_i = 0} $$Differentiating with respect to $\zeta$
$$ \nabla_\zeta = C\mathbf{1} - (\lambda_{i\ldots n} - \lambda_{n+1\ldots 2n}) $$Setting the gradient to 0
$$ \boxed{\lambda_i - \lambda_{2i} = C} $$Let us substitute these results into the Lagrangian equation
$$ \begin{gather} \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i + b\sum_{i}^N \lambda_i y_i -\sum_{i}^N (\lambda_i -\lambda_{2i})\zeta_i\\ = \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i + -\sum_{i}^N (\lambda_i -\lambda_{2i})\zeta_i \tag{$\sum_i \lambda_i y_i = 0$}\\ = \frac{1}{2}\|w\|_2^2 + C \sum_i^N \zeta_i + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i + -C \sum_{i}^N \zeta_i \tag{$\lambda_i - \lambda_{2i} =C$}\\ = \frac{1}{2}\|w\|_2^2 + \sum_{i}^N\lambda_i -\sum_{i}^N \lambda_i y_i w^T x_i\\ = \frac{1}{2}(\sum_i^N y_i \lambda_i x_i)^T(\sum_i^N y_i \lambda_i x_i) + \sum_{i}^N\lambda_i - (\sum_i^N y_i \lambda_i x_i)^T\sum_{i}^N \lambda_i y_i x_i \tag{$w = \sum_i^N x_i \lambda_i y_i$}\\ = \sum_i^N\lambda_i -\frac{1}{2}(\sum_i^N y_i \lambda_i x_i)^T(\sum_i^N y_i \lambda_i x_i) \\ g(\lambda) = \sum_i^N\lambda_i -\frac{1}{2}(\sum_i^N y_i \lambda_i x_i)^T(\sum_i^N y_i \lambda_i x_i) \\ \end{gather} $$Hence the dual problem is
$$ \begin{align} \text{maximize}\quad & \sum_i^N \lambda_i - \frac{1}{2} (\sum_i^N \lambda_i y_i x_i)^T (\sum_i^N \lambda_i y_i x_i)\\ \text{subject to}\quad & \lambda \succeq 0 \end{align} $$2 Probit Model
Suppose $y \in \{0, 1\}$ is a random variable given by
$$ y = \begin{cases} 1\quad a^Tu + b + v \le 0 \\ 0 \quad a^Ty + b + v > 0 \end{cases} $$where the vector $u \in \R^n$ is a vector of explanatory variables and $v$ is a zero mean unit variance Gaussian variable. Formulate the ML estimation problem of estimating $a$ and $b$, given date consisting of pairs $(u_i, y_i), i = 1, \ldots, N$ as a convex optimization problem
If $y= 1 \implies a^Tu + b + v \le 0 \implies v \le -a^Tu - b$ As $v\sim N(0, 1)$ we know its CDF $\Phi(v)$. Hence $\Pr(y = 1) = \Pr(v \le -a^Tu - b) = \Phi(-a^Tu - b)$
As $y=0$ is just the negation of the original condition we have $\Pr(v \gt -a^Tu - b) = 1 - \Phi(-a^Tu-b)$.
Order the samples as $u_1, \ldots, u_q, u_q+1, \ldots u_m$ such that $y_1 \ldots y_q = 1$ and $y_{q+1}\ldots y_m = 0$
$$ \prod_i^q \Phi(-a^Tu_i - b) \prod_{i = q+1}^{m} 1 - \Phi(-a^Tu_i - b) $$The log likelihood then becomes
$$ l(a, b) = \sum_{i = 1}^q \log \Phi(-a^Tu_i - b) + \sum_{i = q+1}^m \log (1 - \Phi(-a^Tu_i - b)) $$We know that the Gaussian cumulative distribution function is log-concave. Non-negative summation of concave functions is still concave. Affine composition of a concave function is still concave. Hence $l(a, b)$ is a concave function.
ML problem then becomes
$$ \begin{align} \text{maximize}\quad&\sum_{i = 1}^q \log \Phi(-a^Tu_i - b) + \sum_{i = q+1}^m \log (1 - \Phi(-a^Tu_i - b))\\ \end{align} $$This is an unconstrained optimization problem. $\Phi$ sucks in any $\R$ and spits out a probability. This makes it so that $\log$ always has valid inputs.
3) Separation of Ellipsoids
Let $\mathcal{E}_1, \mathcal{E}_2$ be two ellipsoids defined as
$$ \mathcal{E}_1 = \{x | (x - x_1)^t P_1^{-1} (x - x_1) \le 1\}\\ \mathcal{E}_2 = \{x | (x - x_2)^t P_2^{-2} (x - x_2) \le 1\} $$Where $P_1, P_2 \in \mathbf{S}^n_{++}$. Show that $\mathcal{E}_1 \cap \mathcal{E}_2 = \emptyset$ if and only if there exists an $a \in \R^n$ with
$$ \|P_1^{1/2}a\|_2 + \|P_2^{1/2}a\|_2 < a^T(x_1 - x_2) $$Let us first express the problem of finding the distance between two convex sets
$$ \begin{align} \text{minimize}\quad & \|x - y\|_2 \\ \text{subject to}\quad& (x - x_1)^T P_1^{-1} (x - x_1) - 1 \le 0\\ & (y - x_2)^T P_2^{-1} (y - x_2) - 1 \le 0 \end{align} $$Equivalently written as
$$ \begin{align} \text{minimize}\quad & \|w\|_2 \\ \text{subject to}\quad& (x - x_1)^T P_1^{-1} (x - x_1) - 1 \le 0\\ & (y - x_2)^T P_2^{-1} (y - x_2) - 1 \le 0\\ & x - y = w \end{align} $$The dual of this problem is
$$ \begin{align} \text{maximize}\quad & \inf_x\{ \lambda\left( (x - x_1)^T P_1^{-1} (x - x_1) - 1 \right) + z^Tx\} \\ &+ \inf_y\{ \mu\left( (y - x_2)^T P_2^{-1} (y - x_2) - 1 \right) - z^Ty\} \\ \text{subject to}\quad& \|z\|_* \le 1\\ & \lambda \succeq 0, \mu \succeq 0 \end{align} $$Let us first solve $\inf_x\{ \lambda\left( (x - x_1)^T P_1^{-1} (x - x_1) - 1 \right) + z^Tx\}$
Differentiating w.r.t $x$ we get $2\lambda P^{-1}(x-x_1) + z$
Setting that equal to 0 and solving for $x$
$$ x = \frac{-1}{2\lambda} Pz + x_1 $$Similarly the minimizing $y$ is
$$ y = \frac{1}{2\mu}Pz + x_2 $$Substituting both into $g$ we get
$$ \begin{align} g(\lambda, \mu, z) &= \frac{-1}{4\lambda} z^TP_1z - \lambda + z^Tx_1 - \frac{1}{4\mu}z^T P_2 z - \mu - z^T x_2\\ &= z^T(x_1 - x_2) - \left( \frac{1}{4\lambda}z^T P_1 z + \frac{1}{4\mu} z^TP_2z + \lambda + \mu \right) \end{align} $$Then the dual problem is
$$ \begin{align} \text{maximize}\quad & z^T(x_1 - x_2) - \left( \frac{1}{4\lambda}z^T P_1 z + \frac{1}{4\mu} z^TP_2z + \lambda + \mu \right)\\ \text{subject to}\quad& \|z\|_* \le 1\\ & \lambda \ge 0, \mu \ge 0 \end{align} $$Differentiating w.r.t to $\lambda$ and $\mu$ gives us $\lambda = \frac{\sqrt{z^TP_1z}}{2}$ and $\mu = \frac{\sqrt{z^T P_2 z}}{2}$. As $P_1, P_2 \in S^n_{++}$, these satisfy the constraint. Then our dual problem becomes
$$ \begin{align} \text{maximize}\quad & z^T(x_1 - x_2) - \left(\sqrt{z^TP_1z} + \sqrt{z^T P_2 z}\right)\\ \text{subject to}\quad& \|z\|_* \le 1\\ \end{align} $$The wonders of duality makes it trivial to prove the $\iff$. We see that the optimization problem has 0 duality gap and is strongly dual. Slater’s constraint qualification is satisfied by the center points.
If
$$\mathcal{E}_1 \cap \mathcal{E}_2 = \emptyset\\ \implies p^* > 0 \implies d^* > 0\\ \implies \exists z, \|z\| \le 1\text{ s.t }\\ z^T(x_1 - x_2) - \left(\sqrt{z^TP_1z} + \sqrt{z^T P_2 z}\right) > 0\\ = z^T(x_1 - x_2) > \left(\sqrt{z^TP_1z} + \sqrt{z^T P_2 z}\right)\\ = z^T(x_1 - x_2) > \sqrt{z^TP_1^{\frac{1}{2}}P_1^{\frac{1}{2}}z} + \sqrt{z^TP_2^{\frac{1}{2}}P_2^{\frac{1}{2}}z}\\ = z^T(x_1 - x_2) > \sqrt{(P_1^{\frac{1}{2}}z)^TP_1^{\frac{1}{2}}z} + \sqrt{(P_2^{\frac{1}{2}}z)^TP_2^{\frac{1}{2}}z}\\ = z^T(x_1 - x_2) > \|P_1^{\frac{1}{2}}z\| + \|P_2^{\frac{1}{2}} z\|\\ \implies \boxed{\|P_1^{\frac{1}{2}}z\| + \|P_2^{\frac{1}{2}} z\| < z^T(x_1 - x_2)} $$Similarly if $\exists z\text{ s.t. }\|P_1^{\frac{1}{2}}z\| + \|P_2^{\frac{1}{2}} z\| < z^T(x_1 - x_2)\implies d > 0 \implies d^* > 0 \implies p^* > 0 \implies \mathcal{E}_1 \cup \mathcal{E}_2 = \emptyset\quad\quad\square$
The two directions are slightly different.
- If the primal problem has a positive value then there exists a dual optimal point that attains the same value. If the two sets are disjoint then there exists a separating hyperplane exactly in the middle of the two centers (I’m not sure about this. In my head the minimum distance between two sets is the maximum ball you can fit between their boundaries).
- If the dual problem has a positive value then the primal problem must also be positive. That is, if you can find any separating hyperplanes, then the sets must be disjoint.
4) Estimating Gaussian Graphical Models
A Gaussian graphical model is simply a multivariate normal distribution, parameterized by a mean $\mu\in\R^n$ precision matrix $\Omega = \Sigma^{-1} \in S^n_{++}$, the inverse of the covariance matrix. The pdf is
$$ p(x; \mu, \Omega) = \frac{|\Omega|^{1/2}}{(2\pi)^{n/2}}\exp(-\frac{1}{2}(x-\mu)^T \Omega (x-\mu)) $$a) Let $x=(x_1, x_2, \ldots, x_n)$ be a multivariate normal variable as above. Two coordinates $x_i$ and $x_j$ are said to be conditionally independent if
$$ p(x_i, x_j | \tilde{x}) = p(x_i | \tilde{x})p(x_j | \tilde{x}) $$Where $\tilde{x} = \{x_k : k\ne i, k \ne j\}$. Prove that $x_i, x_j$ are conditionally independent if $\Omega_{ij}=0$