Algorithm Search⌘K

Proofs: Random projection tree

These are the human proofs of Random projection tree, at full length.

The RP-tree partitions the points, has logarithmic depth with distinct projections, and its branch and bound search is exact full

This proof shows: correctness.

We use the names of the pseudocode on the page. Fix the points P={x0,…,xn−1}⊂RDP = \{x_0, \ldots, x_{n-1}\} \subset \mathbb{R}^D, the leaf size n0≥1n_0 \ge 1, and any sequence of directions, each normalized to unit length. Ties in distance are broken by index, so "the kk nearest" means the kk smallest pairs (∥q−xi∥,i)(\|q - x_i\|, i).

Lemma 1 (structure). BUILD(S)(S) terminates, and the tree it returns satisfies (I1) to (I3) for SS.

Proof. By induction on ∣S∣|S|. If line L1 or line L5 returns a leaf, (I1) holds, (I2) is empty, and (I3) holds: either ∣S∣≤n0|S| \le n_0, or line L5 found R=∅R = \emptyset, so every v⋅x≤tv \cdot x \le t; since tt is one of the projections and is their lower median, and no projection exceeds it, all projections equal tt. Otherwise R≠∅R \ne \emptyset, and L≠∅L \ne \emptyset since the point of rank ⌈∣S∣/2⌉\lceil |S|/2 \rceil has projection tt and goes to LL. So both LL and RR are smaller than SS, the recursive calls terminate and satisfy the invariants for LL and RR by induction, LL and RR partition SS, and line L4 defines them by v⋅x≤tv \cdot x \le t and v⋅x>tv \cdot x > t. This gives (I1) and (I2) at the new node, and (I3) at its leaves. □\square

Lemma 2 (depth). If, at every node, the projections of its points are distinct, then every leaf has at most n0n_0 points and the depth is 00 for n≤n0n \le n_0 and ⌈log⁡2(n/n0)⌉\lceil \log_2(n/n_0) \rceil for n>n0n > n_0.

Proof. With distinct projections, LL consists of the points of rank 1,…,⌈m/2⌉1, \ldots, \lceil m/2 \rceil of a set of size mm, so ∣L∣=⌈m/2⌉≥1|L| = \lceil m/2 \rceil \ge 1 and ∣R∣=⌊m/2⌋≥1|R| = \lfloor m/2 \rfloor \ge 1 when m≥2m \ge 2; in particular line L5 never fires, so a node becomes a leaf exactly when m≤n0m \le n_0. By induction every node at depth jj has at most ⌈n/2j⌉\lceil n/2^j \rceil points, using ⌈⌈a⌉/2⌉=⌈a/2⌉\lceil \lceil a \rceil / 2 \rceil = \lceil a/2 \rceil, and the leftmost node at depth jj has exactly that many. So a leaf appears on every path once ⌈n/2j⌉≤n0\lceil n/2^j \rceil \le n_0, and the leftmost path continues while ⌈n/2j⌉>n0\lceil n/2^j \rceil > n_0. Since n0n_0 is an integer, ⌈n/2j⌉≤n0\lceil n/2^j \rceil \le n_0 iff n/2j≤n0n/2^j \le n_0 iff j≥log⁡2(n/n0)j \ge \log_2(n/n_0). The depth is the least such jj, which is ⌈log⁡2(n/n0)⌉\lceil \log_2(n/n_0) \rceil. □\square

Lemma 3 (the pruning bound). Let a node have direction vv, ∥v∥=1\|v\| = 1, and threshold tt, and let g=v⋅q−tg = v \cdot q - t. If g≤0g \le 0, every point xx of the right subtree has ∥q−x∥>∣g∣\|q - x\| > |g|. If g>0g > 0, every point xx of the left subtree has ∥q−x∥≥∣g∣\|q - x\| \ge |g|.

Proof. By Cauchy-Schwarz, ∥q−x∥≥∣v⋅(q−x)∣\|q - x\| \ge |v \cdot (q - x)|. If g≤0g \le 0 and xx is on the right, v⋅x>tv \cdot x > t by (I2), so v⋅x−v⋅q>t−v⋅q=∣g∣v \cdot x - v \cdot q > t - v \cdot q = |g|. If g>0g > 0 and xx is on the left, v⋅x≤tv \cdot x \le t, so v⋅q−v⋅x≥v⋅q−t=∣g∣v \cdot q - v \cdot x \ge v \cdot q - t = |g|. □\square

Theorem (exact search). QUERY(root,q,k,∅)(root, q, k, \emptyset) leaves in HH the min⁡(k,n)\min(k, n) smallest pairs (∥q−xi∥,i)(\|q - x_i\|, i).

Proof. HH keeps, by the offers of line L7, the kk smallest pairs among the points evaluated so far, and every evaluated point is a point of PP. So it suffices to show that every point among the true min⁡(k,n)\min(k, n) nearest is evaluated, or that the final HH holds kk pairs all at most the pairs of the unevaluated points. Take any point xx that is not evaluated. Then some call skipped a far subtree containing xx at line L11, at a time when ∣H∣=k|H| = k and ∣g∣|g| was larger than the largest distance β\beta in HH. By Lemma 3, ∥q−x∥≥∣g∣>β\|q - x\| \ge |g| > \beta. The largest pair of HH never increases after HH is full, so at the end every pair of HH has distance at most β<∥q−x∥\beta < \|q - x\|, and xx does not belong to the kk smallest pairs. Hence the kk smallest pairs of PP are all evaluated, and HH holds them. If k>nk > n then ∣H∣<k|H| < k at every test of line L11, nothing is skipped, all nn points are evaluated, and HH holds all of them. ■\blacksquare

Back to Random projection tree