Geometric Median in Nearly Linear Time
Michael B. Cohen, Yin Tat Lee, Gary Miller, Jakub Pachocki, Aaron Sidford
Introduction
This problem, also known as the geometric median problem, is well studied and has numerous applications. It is often considered over low dimensional spaces in the context of the facility location problem and over higher dimensional spaces it has applications to clustering in machine learning and data analysis. For example, computing the geometric median is a subroutine in popular expectation maximization heuristics for -medians clustering.
Our time algorithm is a careful modification of standard interior point methods for solving the geometric median problem. We provide a long step interior point method tailored to the geometric median problem for which we can implement every iteration in nearly linear time. While our analysis starts with a simple time interior point method and shows how to improve it, our final algorithm is quite non-standard from the perspective of interior point literature. Our result is one of very few cases we are aware of outperforming traditional interior point theory and the only we are aware of using interior point methods to obtain a nearly linear time algorithm for a canonical optimization problem that traditionally requires superlinear time. We hope our work leads to further improvements in this line of research.
Our algorithm is a relatively straightforward application of sampling techniques and stochastic subgradient descent. Some additional insight is required simply to provide a rigorous analysis of the robustness of the geometric median and use this to streamline our application of stochastic subgradient descent. We include it for completeness however, we defer its proof to Appendix C. The bulk of the work in this paper is focused on developing our time algorithm which we believe uses a set of techniques of independent interest.
The geometric median problem was first formulated for the case of three points in the early 1600s by Pierre de Fermat . A simple elegant ruler and compass construction was given in the same century by Evangelista Torricelli. Such a construction does not generalize when a larger number of points is considered: Bajaj has shown the even for five points, the geometric median is not expressible by radicals over the rationals . Hence, the -approximate problem has been studied for larger values of .
we instead write the problem as minimizing a linear function over a convex set:
Clearly, these problems are the same as at optimality .
Difficulties
Unfortunately obtaining a nearly linear time algorithm for geometric median using interior point methods as presented poses numerous difficulties. Particularly troubling is the number of iterations required by standard interior point algorithms. The approach outlined in the previous section produced an -self concordant barrier and even if we use more advanced self concordance machinery, i.e. the universal barrier , the best known self concordance of barrier for the convex set is . An interesting open question still left open by our work is to determine what is the minimal self concordance of a barrier for this set.
Consequently, even if we could implement every iteration of an interior point scheme in nearly linear time it is unclear whether one should hope for a nearly linear time interior point algorithm for the geometric median. While there are a instances of outperforming standard self-concordance analysis , these instances are few, complex, and to varying degrees specialized to the problems they solve. Moreover, we are unaware of any interior point scheme providing a provable nearly linear time for a general nontrivial convex optimization problem.
Beyond Standard Interior Point
Despite these difficulties we do obtain a nearly linear time interior point based algorithm that only requires iterations, i.e. increases to the path parameter. After choosing the natural penalty functions described above, we optimize in closed form over the to obtain the following penalized objective function:It is unclear how to extend our proof for the simpler function: .
In fact, we show that this movement over such a long step, i.e. a constant increase in , in the directions orthogonal to the bad direction is small enough that for any movement around a ball of this size the Hessian of only changes by a small multiplicative constant. In short, starting at there exists a point obtained just by moving from in the bad direction, such that is close enough to that standard first order method will converge quickly to ! Thus, we might hope to find such a , quickly converge to and repeat. If we increase by a multiplicative constant in every such iterations, standard interior point theory suggests that iterations suffices.
Building an Algorithm
To turn the structural result in the previous section into a fast algorithm there are several further issues we need to address. We need to
(1) Show how to find the point along the bad direction that is close to
(2) Show how to solve linear systems in the Hessian to actually converge quickly to
(4) Bound the accuracy required by these computations
Deferring (1) for the moment, our solution to the rest are relatively straightforward. Careful inspection of the Hessian of reveals that it is well approximated by a multiple of the identity matrix minus a rank 1 matrix. Consequently using explicit formulas for the inverse of of matrix under rank 1 updates, i.e. the Sherman-Morrison formula, we can solve such systems in nearly linear time thereby addressing (2). For (3), we show that the well known power method carefully applied to the Hessian yields the bad direction if it exists. Finally, for (4) we show that a constant approximate geometric median is near enough to the central path for and that it suffices to compute a central path point at to compute a -geometric median. Moreover, for these values of , the precision needed in other operations is clear.
The more difficult operation is (1). Given and the bad direction exactly, it is still not clear how to find the point along the bad direction line from that is close to . Just performing binary search on the objective function a priori might not yield such a point due to discrepancies between a ball in Euclidean norm and a ball in hessian norm and the size of the distance from the optimal point in euclidean norm. To overcome this issue we still line search on the bad direction, however rather than simply using as the objective function to line search on, we use the function for some constant , that is given an we move in the bad direction and take the best objective function value in a ball around that point. For appropriate choice of the minimizers of will include the optimal point we are looking for. Moreover, we can show that is convex and that it suffices to perform the minimization approximately.
Putting these pieces together yields our result. We perform iterations of interior point (i.e. increasing ), where in each iteration we spend time to compute a high quality approximation to the bad direction, and then we perform approximate evaluations on to binary search on the bad direction line, and then to approximately evaluate we perform gradient descent in approximate Hessian norm to high precision which again takes time. Altogether this yields a time algorithm to compute a geometric median. Here we made minimal effort to improve the log factors and plan to investigate this further in future work.
In addition to providing a nearly linear time algorithm we provide a stand alone result on quickly computing a crude -approximate geometric median in Section C. In particular, given an oracle for sampling a random we provide an , i.e. sublinear, time algorithm that computes such an approximate median. Our algorithm for this result is fairly straightforward. First, we show that random sampling can be used to obtain some constant approximate information about the optimal point in constant time. In particular we show how this can be used to deduce an Euclidean ball which contains the optimal point. Second, we perform stochastic subgradient descent within this ball to achieve our desired result.
4 Paper Organization
The rest of the paper is structured as follows. After covering preliminaries in Section 2, in Section 3 we provide various results about the central path that we use to derive our nearly linear time algorithm. In Section 4 we then provide our nearly linear time algorithm. All the proofs and supporting lemmas for these sections are deferred to Appendix A and Appendix B. In Appendix C we provide our algorithm, in Appendix D we provide the derivation of our penalized objective function, in Appendix E we provide general technical machinery we use throughout and in Appendix F we show how to extend our results to Weber’s problem, i.e. weighted geometric median.
Notation
2 Problem Notation
3 Penalized Objective Notation
To solve this problem, we smooth the objective function and instead consider the following family of penalized objective functions parameterized by
Properties of the Central Path
Here provide various facts regarding the penalized objective function and the central path. While we use the lemmas in this section throughout the paper, the main contribution of this section is Lemma 5 in Section 3.3. There we prove that with the exception of a single direction, the change in the central path is small over a constant multiplicative change in the path parameter. In addition, we show that our penalized objective function is stable under changes in a Euclidean ball (Section 3.1), we bound the change in the Hessian over the central path (Section 3.2), and we relate to (Section 3.4).
Here, we show that the Hessian of the penalized objective function is stable under changes in a sized Euclidean ball. This shows that if we have a point which is close to a central path point in Euclidean norm, then we can use Newton method to find it.
Suppose that with . Then, we have
2 How Much Does the Hessian Change Along the Path?
Here we bound how much the Hessian of the penalized objective function can change along the central path. First we provide the following lemma bound several aspects of the penalized objective function and proving that the weight, , only changes by a small amount multiplicatively given small multiplicative changes in the path parameter, .
For all and the following hold
Consequently, for all we have that .
Next we use this lemma to bound the change in the Hessian with respect to .
and therefore for all
3 Where is the Next Optimal Point?
Here we prove our main result of this section. We prove that over a long step the central path moves very little in directions orthogonal to the smallest eigenvector of the Hessian. We begin by noting the Hessian is approximately a scaled identity minus a rank 1 matrix.
Using this and the lemmas of the previous section we bound the amount can move in every direction far from .
For all , , and any unit vector with where , we have .
4 Where is the End?
In this section, we bound the quality of the central path with respect to the geometric median objective. In particular, we show that if we can solve the problem for some then we obtain an -approximate solution. As our algorithm ultimately starts from an initial and increases by a multiplicative constant in every iteration, this yields an iteration algorithm.
for all .
Nearly Linear Time Geometric Median
Here we show how to use the structural results from the previous section to obtain a nearly linear time algorithm for computing the geometric median. Our algorithm follows a simple structure (See Algorithm 1). First we use simply average the to compute a 2-approximate median, denoted . Then for a number of iterations we repeatedly move closer to for some path parameter , compute the minimum eigenvector of the Hessian, and line search in that direction to find an approximation to a point further along the central path. Ultimately, this yields a point that is precise enough approximation to a point along the central path with large enough that we can simply out as our -approximate geometric median.
Furthermore, we show that the computed by this algorithm is sufficiently close to the bad direction. Combining 7 with the structural results from the previous section and Lemma 28, a minor technical lemma regarding the transitivity of large inner products,we provide the following lemma.
Let for and for . If then with high probability in for all unit vectors , we have .
Note that this lemma assumes is small. When is large, we instead show that the next central path point is close to the current point and hence we do not need to compute the bad direction to center quickly.
Suppose and let then .
2 Line Searching
Here we show how to line search along the bad direction to find the next point on the central path. Unfortunately, simply performing binary search on objective function directly may not suffice. If we search over to minimize it is unclear if we actually obtain a point close to . It might be the case that even after minimizing we would be unable to move towards efficiently.
To overcome this difficulty, we use the fact that over the region the Hessian changes by at most a constant and therefore we can minimize over this region extremely quickly. Therefore, we instead line search on the following function
and use that we can evaluate approximately by using an appropriate centering procedure. We can show (See Lemma 30) that is convex and therefore we can minimize it efficiently just by doing an appropriate binary search. By finding the approximately minimizing and outputting the corresponding approximately minimizing , we can obtain that is close enough to . For notational convenience, we simply write if is clear from the context.
First, we show how we can locally center and provide error analysis for that algorithm.
Using this local centering algorithm as well as a general result for minimizing one dimensional convex functions using a noisy oracle (See Section E.3) we obtain our line search algorithm.
We also provide the following lemma useful for finding the first center.
3 Putting It All Together
Combining the results of the previous sections, we prove our main theorem.
In time, Algorithm 1 outputs an -approximate geometric median with constant probability.
Acknowledgments
We thank Yan Kit Chim, Ravi Kannan, and Jonathan A. Kelner for many helpful conversations. We thank the reviewers for their help in completing the previous work table. This work was partially supported by NSF awards 0843915, 1065106 and 1111109, NSF Graduate Research Fellowship (grant no. 1122374) and Sansom Graduate Fellowship in Computer Science. Part of this work was done while authors were visiting the Simons Institute for the Theory of Computing, UC Berkeley.
References
Appendix A Properties of the Central Path (Proofs)
Here we provide proofs of the claims in Section 3 as well as additional technical lemmas we use throughout the paper.
Here we provide basic facts regarding the central path that we will use throughout our analysis. First we compute various derivatives of the penalized objective function.
and solving for then yields
Next, in we provide simple facts regarding the Hessian of the penalized objective function.
A.2 Stability of Hessian
Here we prove the following stronger statement, for all
where we used that and (since ). Now we know that and therefore, by Young’s inequality and Cauchy Schwarz we have that for all
Now, we separate the proof into two cases depending if .
If then since we have that
and , justifying our assumption that and . Furthermore, this implies that
and therefore letting yields
Since and are unit vectors, both and are less than
Otherwise, and therefore
Therefore independent of (A.1) and the assumption that and we have
Now, we note that . Therefore, by Lemma 15 we have that
Since , the result follows. ∎
Consequently, so long as we have a point within a sized Euclidean ball of some , Newton’s method (or an appropriately transformed first order method) within the ball will converge quickly.
A.3 How Much Does the Hessian Change Along the Path?
Using this fact and the fact that we have
which by Cauchy Schwarz and that yields the second equation. Furthermore,
which yields the third equation. Therefore, we have that
Exponentiating the above inequality yields the final inequality. ∎
and therefore by Lemma 2 and the fact that we have
which completes the proof of (3.1). To prove (3.2), let be any unit vector and note that
where we used Lemma 3 and at the last line. ∎
A.4 Where is the next Optimal Point?
This follows immediately from Lemma 14, regarding the hessian of the penalized objective function, and Lemma 25, regarding the sum of PSD matrices expressed as the identity matrix minus a rank 1 matrix. ∎
Now since clearly , invoking Lemma 2 yields that
Now by invoking Lemma 3 and the Lemma 4, we have that
Let be the subspace orthogonal to . Then, Lemma 4 shows that on and hence on .By on we mean that for all we have . The meaning of on is analagous. Since , we have that
Now, we split where . Then, we have that
Combining these and using that yields that
A.5 Where is the End?
Therefore, by Cauchy Schwarz and the fact that
Furthermore, since we have
A.6 Simple Lemmas
Here we provide various small technical Lemmas that we will use to bound the accuracy with which we need to carry out various operations in our algorithm. Here we use some notation from Section 4 to simplify our bounds and make them more readily applied.
For any , we have that
For the final inequality, we use the fact that and the fact that by Lemma 6 and get
For the second inequality, note that Lemma 14 and Lemma 18 yields that
Consequently, applying 29 again yields the lower bound.∎
Appendix B Nearly Linear Time Geometric Median (Proofs)
Here we provide proofs, algorithms, and technical lemmas from Section 4.
We write . Then, we have
where we used that
where is the indicator vector for coordinate . Consequently is -Lipschitz and by Gaussian concentration for Lipschitz functions we know there are absolute constants and such that
By the concavity of square root and the expected value of the chi-squared distribution we have
Consequently, since we have that for and that with high probability in . Since , we have with high probability in . Furthermore, this implies that
By Lemma 4 we know that where
Consequently, if , then for all unit vectors , we have that
Therefore, in this case, has a constant multiplicative gap between its top two eigenvectors and stable rank at most a constant (i.e. and in Theorem 20). Consequently, by Theorem 20 we have .
On the other hand, by Lemma 26, we have that
By Lemma 7 we know that . Since clearly , by assumption, Lemma 1 shows
Furthermore, since , as in Lemma 7 we know that the largest eigenvalue of defined in is at least while the second largest eigenvalue is at most . Consequently, the eigenvalue gap, , defined in Lemma 27 is at least and this lemma shows that . Consequently, by Lemma 28, we have that .
To prove the final claim, we write for an unit vector . Since , we have that . Then, either and the result follows or and since , we have
where in the last line we used that since . ∎
Consequently, by Lemma 13, the fact that , and Lemma 2 we have
B.2 Line Searching
Here we prove the main results we use on centering, Lemma 10, and line searching Lemma 11. These results are our main tools for computing approximations to the central path. To prove Lemma 11 we also include here two preliminary lemmas, Lemma 21 and Lemma 22, on the structure of defined in (4.1).
The guarantee on then follows from our choice of .
For the running time, Lemma 7 showed the cost of is . Using Lemma 31 we see that the cost per iteration is and therefore, the total cost of the iterations is . Combining yields the running time. ∎
Next, by Lemma 13, triangle inequality, and the fact that we have
If then by Lemma 8 and our choice of we have that if then
Otherwise, we have and by Lemma 9 we have .
In either case, since , we can reach from by first moving an Euclidean distance of to go from to , then adding some multiple of , then moving an Euclidean distance of in a direction perpendicular to . Since the total movement perpendicular to is we have that as desired.
All that remains is to show that there is a minimizer of in the range . However, by Lemma 6 and Lemma 16 we know that
Consequently, as desired. ∎
By (B.3) we know that is Lipschitz and therefore
Furthermore, for we know that by Lemma 16
The proof is strictly easier than the proof of Lemma 11 as is satisfied automatically for Note that this lemma assume less for the initial point. ∎
B.3 Putting It All Together
Appendix C Pseudo Polynomial Time Algorithm
We first prove that the geometric median is stable even if we are allowed to modify up to half of the points. The following lemma is a strengthening of the robustness result in .
Let be a geometric median of and let with . For all
For notational convenience let and let .
For all , we have that , hence, we have
Furthermore, by triangle inequality for all , we have
Since is a minimizer of , we have that
Now, we use Lemma 23 to show that the algorithm outputs a constant approximation of the geometric median with high probability.
Let be a geometric median of and be the output of . We define be the -percentile of . Then, we have that . Furthermore, with probability , we have
Lemma 23 shows that for all and with
Picking to be the indices of largest 40% of , we have
For any point , we have that with probability because is a random subset of with size . Taking union bound over elements on , with probability , for all points
yielding that .
Again, since is a random subset of with size , we have that with probability . Therefore,
Since is an independent random subset, with probability , there is such that . In this case, we have
Since minimize over all , we have that
C.2 A 1+ϵ1italic-ϵ1+\epsilon Approximation of Geometric Median
1italic-ϵ1+\epsilon Approximation of Geometric Median Here we show how to improve the constant approximation in the previous section to a approximation. Our algorithm is essentially stochastic subgradient where we use the information from the previous section to bound the domain in which we need to search for a geometric median.
Let be the output of . With probability , we have
Furthermore, the algorithm takes time.
(see [5, Thm 6.1]). Lemma 24 shows that and with probability . In this case, we have
Since , we have
Appendix D Derivation of Penalty Function
Here we derive our penalized objective function. Consider the following optimization problem:
Since is convex in , the minimum must satisfy
Solving for such under the restriction we obtain
If we drop the terms that do not affect the minimizing we obtain our penalty function :
Appendix E Technical Facts
Here we provide various technical lemmas we use through the paper.
First we provide the following lemma that shows that any matrix obtained as a non-negative linear combination of the identity minus a rank 1 matrix less than the identity results in a matrix that is well approximated spectrally by the identity minus a rank 1 matrix. We use this lemma to characterize the Hessian of our penalized objective function and thereby imply that it is possible to apply the inverse of the Hessian to a vector with high precision.
Consequently, and the result holds by the monotonicity of . ∎
Next we bound the spectral difference between the outer product of two unit vectors by their inner product. We use this lemma to bound the amount of precision required in our eigenvector computations.
For unit vectors and we have
Consequently if for we have that
Note that is a symmetric matrix and all eigenvectors are either orthogonal to both and (with eigenvalue 0) or are of the form where and are real numbers that are not both . Thus, if is an eigenvector of non-zero eigenvalue it must be that
By computing the determinant we see this has a solution only when
Solving for then yields (E.1) and completes the proof. ∎
Next we show how the top eigenvectors of two spectrally similar matrices are related. We use this to bound the amount of spectral approximation we need to obtain accurate eigenvector approximations.
Furthermore, by the optimality of we have that
Now since combining these inequalities yields
Rearranging terms, using the definition of , and that and yields
Here we prove a an approximate transitivity lemma for inner products of vectors. We use this to bound the accuracy need for certain eigenvector computations.
Without loss of generality, we can write for and unit vector . Similarly we can write for and unit vector . Now, by the inner products we know that and and therefore and . Consequently, since , , and we have
E.2 Convex Optimization
First we provide a single general lemma about about first order methods for convex optimization. We use this lemma for multiple purposes including bounding errors and quickly compute approximations to the central path.
Next we provide a short technical lemma about the convexity of functions that arises naturally in our line searching procedure.
Let be the solution of this problem. If , then . Otherwise, there is such that is the minimizer of
Let . Then, the optimality condition of the above equation shows that
Let , then we have and hence Sherman–Morrison formula shows that
Let and , then we have
Note that this is a polynomial of degree in and all coefficients can be computed in time. Solving this by explicit formula, one can test all 4 possible ’s into the formula (E.3) of . Together with trivial case , we simply need to check among cases to check which is the solution.∎
E.3 Noisy One Dimensional Convex Optimization
Here we show how to minimize a one dimensional convex function giving a noisy oracle for evaluating the function. While this could possibly be done using general results on convex optimization with a membership oracle, the proof in one dimension is much simpler and we provide it here for completeness.
Appendix F Weighted Geometric Median
First, we show that it suffices to consider the case where the weights are integers with bounded sum (Lemma 33). Then, we show that such an instance of the weighted geometric median problem can be solved using the algorithms developed for the unweighted problem.
Any -approximate weighted geometric median of with the weights is also a -approximate weighted geometric median of with the weights , and
are nonnegative integers and .
and . Furthermore, let and for each , define , and . We also define analogously to and .
Now, assume , where is the minimizer of and . Then:
Now, since and we have
We now proceed to show the main result of this section.
By applying Lemma 33, we can assume that the weights are integer and their sum does not exceed Note that computing the weighted geometric median with such weights is equivalent to computing an unweighted geometric median of points (where each point of the original input is repeated with the appropriate multiplicity). We now show how to simulate the behavior of our unweighted geometric median algorithms on such a set of points without computing it explicitly.
If , we will apply the algorithm , achieving a runtime of . It is only necessary to check that we can implement weighted sampling from our points with preprocessing and time per sample. This is achieved by the alias method .
Now assume . We will employ the algorithm . Note that we can implement the subroutines and on the implicitly represented multiset of points. It is enough to observe only of the points are distinct, and all computations performed by these subroutines are identical for identical points. The total runtime will thus be .∎