# Randomized Algorithms (Spring 2010)/More on Chernoff bounds

### Set balancing

Supposed that we have an ${\displaystyle n\times m}$ matrix ${\displaystyle A}$ with 0-1 entries. We are looking for a ${\displaystyle b\in \{-1,+1\}^{m}}$ that minimizes ${\displaystyle \|Ab\|_{\infty }}$.

Recall that ${\displaystyle \|\cdot \|_{\infty }}$ is the infinity norm (also called ${\displaystyle L_{\infty }}$ norm) of a vector, and for the vector ${\displaystyle c=Ab}$,

${\displaystyle \|Ab\|_{\infty }=\max _{i=1,2,\ldots ,n}|c_{i}|}$.

We can also describe this problem as an optimization:

{\displaystyle {\begin{aligned}{\mbox{minimize }}&\quad \|Ab\|_{\infty }\\{\mbox{subject to: }}&\quad b\in \{-1,+1\}^{m}.\end{aligned}}}

This problem is called set balancing for a reason.

 The problem arises in designing statistical experiments. Suppose that we have ${\displaystyle m}$ subjects, each of which may have up to ${\displaystyle n}$ features. This gives us an ${\displaystyle n\times m}$ matrix ${\displaystyle A}$: ${\displaystyle {\begin{array}{c}{\mbox{feature 1:}}\\{\mbox{feature 2:}}\\\vdots \\{\mbox{feature n:}}\\\end{array}}\left[{\begin{array}{cccc}a_{11}&a_{12}&\cdots &a_{1m}\\a_{21}&a_{22}&\cdots &a_{2m}\\\vdots &\vdots &\ddots &\vdots \\a_{n1}&a_{n2}&\cdots &a_{nm}\\\end{array}}\right],}$ where each column represents a subject and each row represent a feature. An entry ${\displaystyle a_{ij}\in \{0,1\}}$ indicates whether subject ${\displaystyle j}$ has feature ${\displaystyle i}$. By multiplying a vector ${\displaystyle b\in \{-1,+1\}^{m}}$ ${\displaystyle \left[{\begin{array}{cccc}a_{11}&a_{12}&\cdots &a_{1m}\\a_{21}&a_{22}&\cdots &a_{2m}\\\vdots &\vdots &\ddots &\vdots \\a_{n1}&a_{n2}&\cdots &a_{nm}\\\end{array}}\right]\left[{\begin{array}{c}b_{1}\\b_{2}\\\vdots \\b_{m}\\\end{array}}\right]=\left[{\begin{array}{c}c_{1}\\c_{2}\\\vdots \\c_{n}\\\end{array}}\right],}$ the subjects are partitioned into two disjoint groups: one for -1 and other other for +1. Each ${\displaystyle c_{i}}$ gives the difference between the numbers of subjects with feature ${\displaystyle i}$ in the two groups. By minimizing ${\displaystyle \|Ab\|_{\infty }=\|c\|_{\infty }}$, we ask for an optimal partition so that each feature is roughly as balanced as possible between the two groups. In a scientific experiment, one of the group serves as a control group (对照组). Ideally, we want the two groups are statistically identical, which is usually impossible to achieve in practice. The requirement of minimizing ${\displaystyle \|Ab\|_{\infty }}$ actually means the statistical difference between the two groups are minimized.

We propose an extremely simple "randomized algorithm" for computing a ${\displaystyle b\in \{-1,+1\}^{m}}$: for each ${\displaystyle i=1,2,\ldots ,m}$, let ${\displaystyle b_{i}}$ be independently chosen from ${\displaystyle \{-1,+1\}}$, such that

${\displaystyle b_{i}={\begin{cases}-1&{\mbox{with probability }}{\frac {1}{2}}\\+1&{\mbox{with probability }}{\frac {1}{2}}\end{cases}}.}$

This procedure can hardly be called as an "algorithm", because its decision is made disregard of the input ${\displaystyle A}$. We then show that despite of this obliviousness, the algorithm chooses a good enough ${\displaystyle b}$, such that for any ${\displaystyle A}$, ${\displaystyle \|Ab\|_{\infty }=O({\sqrt {m\ln n}})}$ with high probability.

 Theorem Let ${\displaystyle A}$ be an ${\displaystyle n\times m}$ matrix with 0-1 entries. For a random vector ${\displaystyle b}$ with ${\displaystyle m}$ entries chosen independently and with equal probability from ${\displaystyle \{-1,+1\}}$, ${\displaystyle \Pr[\|Ab\|_{\infty }>2{\sqrt {2m\ln n}}]\leq {\frac {2}{n}}}$.
Proof.
 Consider particularly the ${\displaystyle i}$-th row of ${\displaystyle A}$. The entry of ${\displaystyle Ab}$ contributed by row ${\displaystyle i}$ is ${\displaystyle c_{i}=\sum _{j=1}^{m}a_{ij}b_{j}}$. Let ${\displaystyle k}$ be the non-zero entries in the row. If ${\displaystyle k\leq 2{\sqrt {2m\ln n}}}$, then clearly ${\displaystyle |c_{i}|}$ is no greater than ${\displaystyle 2{\sqrt {2m\ln n}}}$. On the other hand if ${\displaystyle k>2{\sqrt {2m\ln n}}}$ then the ${\displaystyle k}$ nonzero terms in the sum ${\displaystyle c_{i}=\sum _{j=1}^{m}a_{ij}b_{j}}$ are independent, each with probability 1/2 of being either +1 or -1. Thus, for these ${\displaystyle k}$ nonzero terms, each ${\displaystyle b_{i}}$ is either positive or negative independently with equal probability. There are expectedly ${\displaystyle \mu ={\frac {k}{2}}}$ positive ${\displaystyle b_{i}}$'s among these ${\displaystyle k}$ terms, and ${\displaystyle c_{i}<-2{\sqrt {2m\ln n}}}$ only occurs when there are less than ${\displaystyle {\frac {k}{2}}-{\sqrt {2m\ln n}}=\left(1-\delta \right)\mu }$ positive ${\displaystyle b_{i}}$'s, where ${\displaystyle \delta ={\frac {2{\sqrt {2m\ln n}}}{k}}}$. Applying Chernoff bound, this event occurs with probability at most {\displaystyle {\begin{aligned}\exp \left(-{\frac {\mu \delta ^{2}}{2}}\right)&=\exp \left(-{\frac {k}{2}}\cdot {\frac {8m\ln n}{2k^{2}}}\right)\\&=\exp \left(-{\frac {2m\ln n}{k}}\right)\\&\leq \exp \left(-{\frac {2m\ln n}{m}}\right)\\&\leq n^{-2}.\end{aligned}}} The same argument can be applied to negative ${\displaystyle b_{i}}$'s, so that the probability that ${\displaystyle c_{i}>2{\sqrt {2m\ln n}}}$ is at most ${\displaystyle n^{-2}}$. Therefore, by the union bound, ${\displaystyle \Pr[|c_{i}|>2{\sqrt {2m\ln n}}]\leq {\frac {2}{n^{2}}}}$. Apply the union bound to all ${\displaystyle n}$ rows. ${\displaystyle \Pr[\|Ab\|_{\infty }>2{\sqrt {2m\ln n}}]\leq n\cdot \Pr[|c_{i}|>2{\sqrt {2m\ln n}}]\leq {\frac {2}{n}}}$.
${\displaystyle \square }$

How good is this randomized algorithm? In fact when ${\displaystyle m=n}$ there exists a matrix ${\displaystyle A}$ such that ${\displaystyle \|Ab\|_{\infty }=\Omega ({\sqrt {n}})}$ for any choice of ${\displaystyle b\in \{-1,+1\}^{n}}$.

## Permutation Routing

The problem raises from parallel computing. Consider that we have ${\displaystyle N}$ processors, connected by a communication network. The processors communicate with each other by sending and receiving packets through the network. We consider the following packet routing problem:

• Every processor is sending a packet to a unique destination. Therefore for ${\displaystyle [N]}$ the set of processors, the destinations are given by a permutation ${\displaystyle \pi }$ of ${\displaystyle [N]}$, such that for every processor ${\displaystyle i\in [N]}$, the processor ${\displaystyle i}$ is sending a packet to processor ${\displaystyle \pi (i)}$.
• The communication is synchronized, such that for each round, every link (an edge of the graph) can forward at most one packet.

With a complete graph as the network. For any permutation ${\displaystyle \pi }$ of ${\displaystyle [N]}$, all packets can be routed to their destinations in parallel with one round of communication. However, such an ideal connectivity is usually not available in reality, either because they are too expensive, or because they are physically impossible. We are interested in the case the graph is sparse, such that the number of edges is significantly smaller than the complete graph, yet the distance between any pair of vertices is small, so that the packets can be efficiently routed between pairs of vertices.

### Routing on a hypercube

A hypercube (sometimes called Boolean cube, Hamming cube, or just cube) is defined over ${\displaystyle N}$ nodes, for ${\displaystyle N}$ a power of 2. We assume that ${\displaystyle N=2^{d}}$. A hypercube of ${\displaystyle d}$ dimensions, or a ${\displaystyle d}$-cube, is an undirected graph with the vertex set ${\displaystyle \{0,1\}^{d}}$, such that for any ${\displaystyle u,v\in \{0,1\}^{d}}$, ${\displaystyle u}$ and ${\displaystyle v}$ are adjacent if and only if ${\displaystyle h(u,v)=1}$, where ${\displaystyle h(u,v)}$ is the Hamming distance between ${\displaystyle u}$ and ${\displaystyle v}$.

A ${\displaystyle d}$-cube is a ${\displaystyle d}$-degree regular graph over ${\displaystyle N=2^{d}}$ vertices. For any pair ${\displaystyle (u,v)}$ of vertices, the distance between ${\displaystyle u}$ and ${\displaystyle v}$ is at most ${\displaystyle d}$. (How do we know this? Since it takes at most ${\displaystyle d}$ steps to fix any binary string of length ${\displaystyle d}$ bit-by-bit to any other.) This directly gives us the following very natural routing algorithm.

 Bit-Fixing Routing Algorithm For each packet: Let ${\displaystyle u,v\in \{0,1\}^{d}}$ be the origin and destination of the packet respectively. For ${\displaystyle i=1}$ to ${\displaystyle d}$, do: if ${\displaystyle u_{i}\neq v_{i}}$ then traverse the edge ${\displaystyle (v_{1},\ldots ,v_{i-1},u_{i},\ldots ,u_{d})\rightarrow (v_{1},\ldots ,v_{i-1},v_{i},u_{i+1}\ldots ,u_{d})}$.
Oblivious routing algorithms
This algorithm is blessed with a desirable property: at each routing step, the choice of link depends only on the the current node and the destination. We call the algorithms with this property oblivious routing algorithms. (Actually, the standard definition of obliviousness allows the choice also depends on the origin. The bit-fixing algorithm is even more oblivious than this standard definition.) Compared to the routing algorithms which are adaptive to the path that the packet traversed, oblivious routing is more simple thus can be implemented by smaller routing table (or simple devices called switches).
Queuing policies
When routing ${\displaystyle N}$ packets in parallel, it is possible that more than one packets want to use the same edge at the same time. We assume that a queue is associated to each edge, such that the packets to be delivered through an edge are put into the queue associated with the edge. With some queuing policy (e.g. FIFO, or furthest to do), the queued packets are delivered through the edge by at most one packet per each round.

For the bit-fixing routing algorithm defined above, regardless of the queuing policy, there always exists a bad permutation ${\displaystyle \pi }$ which specifies the destinations, such that it takes ${\displaystyle \Omega ({\sqrt {N}})}$ steps by the bit-fixing algorithm to route all ${\displaystyle N}$ packets to their destinations. (You can prove this by yourself.)

This is pretty bad, because we expect that the routing time is comparable to the diameter of the network, which is only ${\displaystyle d=\log N}$ for hypercube.

The lower bound actually applies generally for any deterministic oblivious routing algorithms:

 Theorem [Kaklamanis, Krizanc, Tsantilas, 1991] In any ${\displaystyle N}$-node communication network with maximum degree ${\displaystyle d}$, any deterministic oblivious algorithm for routing an arbitrary permutation requires ${\displaystyle \Omega ({\sqrt {N}}/d)}$ parallel communication steps in the worst case.

The proof of the lower bound is rather technical and complicated. However, the intuition is quite clear: for any oblivious rule for routing, there always exists a permutation which causes a very high congestion, such that many packets have to be delivered through the same edge, thus no matter what queuing policy is used, the maximum delay must be very high.

### Average-case Analysis for Independent Destinations

We analyze the average-case performance of the bit-fixing routing algorithm. We relax the problem to non-permutation destinations. That is, instead of restricting that every processor has a distinct destination, we now allow each processor choose an arbitrary destination in ${\displaystyle \{0,1\}^{d}}$.

For the average case, for each node ${\displaystyle v\in \{0,1\}^{d}}$, its destination is a uniformly and independently random node from ${\displaystyle \{0,1\}^{d}}$.

For each node ${\displaystyle v\in \{0,1\}^{d}}$, let ${\displaystyle P_{v}}$ denote the route for ${\displaystyle v}$ to its random destination ${\displaystyle r}$. ${\displaystyle P_{v}}$ is a sequence of edges along the bit-fixing route from ${\displaystyle v}$ to ${\displaystyle r}$.

#### Reduce the delay of a route to the number of packets that pass through the route

We consider the delay incurred by each node, which is the total time that its packet is waiting in the queue. The total running time of the algorithm is bounded by the maximum delay plus ${\displaystyle d}$.

We assume that the queueing policy satisfies a very natural requirement:

Natural queuing assumption
If a queue is not empty at the beginning of a time step, some packet is sent along the edge associated with that queue during that time step.
 Lemma 2.1 With the above assumption of the queuing policy, the delay inccured by ${\displaystyle u}$ is at most the number of packets whose routes pass through at least one edge in ${\displaystyle P_{u}}$.
Proof.
 See Lemma 4.5 in the textbook [MR].
${\displaystyle \square }$

#### Represent the delay as the sum of independent trials

Let the random variable ${\displaystyle H_{uv}}$ indicate whether ${\displaystyle P_{u}}$ and ${\displaystyle P_{v}}$ share at least one edge. That is,

${\displaystyle H_{uv}={\begin{cases}1&{\text{if }}P_{u}{\text{ and }}P_{v}{\text{ share at least one edge}},\\0&{\text{otherwise}}.\end{cases}}}$

Fix a node ${\displaystyle u\in \{0,1\}^{d}}$ and the corresponding route ${\displaystyle P_{u}}$. The random variable ${\displaystyle H_{u}=\sum _{v\in \{0,1\}^{d}}H_{uv}}$ gives the total number of packets whose routes pass through ${\displaystyle P_{u}}$. Due to Lemma 2.1, ${\displaystyle H_{u}}$ gives an upper bound on the delay inccured by ${\displaystyle u}$.

We will then bound ${\displaystyle H_{u}}$. Note that for ${\displaystyle v\neq u}$, ${\displaystyle H_{uv}}$ are independent trials (because the destinations of ${\displaystyle u}$ and ${\displaystyle v}$ are independent), thus we can apply the Chernoff bound. To do so, we must estimate the expectation ${\displaystyle \mathbf {E} [H_{u}]}$.

#### Estimate the expectation of the sum

For any edge ${\displaystyle e}$ in the hypercube, let the random variable ${\displaystyle T(e)}$ denote the number of routes that pass through ${\displaystyle e}$. As we argued above that ${\displaystyle H_{u}}$ is the number of packets that pass though the route ${\displaystyle P_{u}}$, then obviously

${\displaystyle H_{u}\leq \sum _{e\in P_{u}}T(e),}$

where we abuse the notation ${\displaystyle e\in P_{u}}$ to denote the edge ${\displaystyle e}$ appeared in the route ${\displaystyle P_{u}}$.

Therefore,

${\displaystyle \mathbf {E} [H_{u}]\leq \sum _{e\in P_{u}}\mathbf {E} [T(e)].\qquad \qquad (*)}$

For every node ${\displaystyle v\in \{0,1\}^{d}}$, the length of the route ${\displaystyle P_{v}}$, denoted ${\displaystyle |P_{v}|}$, is the number of different bits between ${\displaystyle v}$ and the last node in the route (because of the "bit-fixing"). For the uniformly random destination, ${\displaystyle \mathbf {E} [|P_{v}|]=d/2}$ (a random node in ${\displaystyle \{0,1\}^{d}}$ expectedly flips ${\displaystyle d/2}$ bits in any fixed ${\displaystyle v\in \{0,1\}^{d}}$). Thus,

${\displaystyle \sum _{v\in \{0,1\}^{d}}\mathbf {E} [|P_{v}|]={\frac {dN}{2}}.}$

It is obvious that we can count the sum of lengths of a set of routes by accumulating their passes through edges, that is

${\displaystyle \sum _{v\in \{0,1\}^{d}}|P_{v}|=\sum _{e}T(e),}$

Therefore,

${\displaystyle \sum _{e}\mathbf {E} [T(e)]=\sum _{v\in \{0,1\}^{d}}\mathbf {E} [|P_{v}|]={\frac {dN}{2}},}$

where the sum ${\displaystyle \sum _{e}\mathbf {E} [T(e)]}$ is taken over all edges in the hypercube.

An important observation is that the distribution of ${\displaystyle T(e)}$'s are all symmetric, thus all ${\displaystyle \mathbf {E} [T(e)]}$'s are equal. The number of edges in the hypercube is ${\displaystyle {\frac {dN}{2}}}$. Therefore, for every edge ${\displaystyle e}$ in the hupercube,

${\displaystyle \mathbf {E} [T(e)]={\frac {2}{dN}}\cdot {\frac {dN}{2}}=1.}$

The length of ${\displaystyle P_{u}}$ is at most ${\displaystyle d}$. Due to ${\displaystyle (*)}$, the expectation of ${\displaystyle H_{u}}$ is ${\displaystyle \mathbf {E} [H_{u}]\leq \sum _{e\in P_{u}}\mathbf {E} [T(e)]\leq d}$.

#### Apply the Chernoff bound

We apply the following form of the Chernoff bound:

 Chernoff bound Let ${\displaystyle X=\sum _{i=1}^{n}X_{i}}$, where ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$ are independent Poisson trials. Let ${\displaystyle \mu =\mathbf {E} [X]}$. Then for ${\displaystyle t\geq 2e\mu }$, ${\displaystyle \Pr[X\geq t]\leq 2^{-t}.}$

It holds that ${\displaystyle 6d>2e\mathbf {E} [H_{u}]=2ed}$. By applying the Chernoff bound,

${\displaystyle \Pr[H_{u}>6d]<2^{-6d}}$.

Note that ${\displaystyle H_{u}}$ only gives the bound on the delay incurred by a particular node ${\displaystyle u}$. By the union bound,

{\displaystyle {\begin{aligned}\Pr[{\text{the maximum delay of Phase I}}>6d]&\leq \Pr[\max _{u\in \{0,1\}^{d}}H_{u}>6d]\\&\leq N\Pr[H_{u}>6d]\\&

The running time is the maximum delay plus the length of a route, thus is ${\displaystyle >7d}$ with probability ${\displaystyle <2^{-5d}}$.

### A two-phase randomized routing algorithm

The above analysis of the performance of bit-fixing for independent random destinations hints us that we can first route the packets to random "relay"s to avoid the high congestion. This was first discovered by Leslie Valiant who uses the idea to give a simple and elegant randomized routing algorithm for permutation routing.

The algorithm works in two phases.

 Two-Phase Routing Algorithm For each packet: Phase I: Route the packet to a random destination using the bit-fixing algorithm. Phase II: Route the packet from the random location to its final destination using the bit-fixing algorithm.

It looks counter-intuitive that first routing the packets to irrelevant intermediate nodes actually improves the overall performance.

To simplify the analysis, we assume that no packet is sent in Phase II before all packets have finished Phase I.

Phase I is exactly the bit-fixing routing for uniformly and independently random destinations, which as we analyzed in the last section, has a running time within ${\displaystyle 7d}$ for probability at least ${\displaystyle 1-2^{-5d}}$.

The Phase II is a "backward" running of Phase I. All the analysis of Phase I can be directly applied to Phase II. Thus, the running time of Phase II is ${\displaystyle >7d}$ with probability ${\displaystyle <2^{-5d}}$. By the union bound, the total running time of the randomized routing algorithm is no more than ${\displaystyle 14d=O(\log N)}$ with high probability.

## Low-Distortion Embeddings

Consider a problem as follows: We have a set of ${\displaystyle n}$ points in a high-dimensional Euclidean space ${\displaystyle \mathbf {R} ^{d}}$. We want to project the points onto a space of low dimension ${\displaystyle \mathbf {R} ^{k}}$ in such a way that pairwise distances of the points are approximately the same as before.

Formally, we are looking for a map ${\displaystyle f:\mathbf {R} ^{d}\rightarrow \mathbf {R} ^{k}}$ such that for any pair of original points ${\displaystyle u,v}$, ${\displaystyle \|f(u)-f(v)\|}$ distorts little from ${\displaystyle \|u-v\|}$, where ${\displaystyle \|\cdot \|}$ is the Euclidean norm, i.e. ${\displaystyle \|u-v\|={\sqrt {(u_{1}-v_{1})^{2}+(u_{2}-v_{2})^{2}+\ldots +(u_{d}-v_{d})^{2}}}}$ is the distance between ${\displaystyle u}$ and ${\displaystyle v}$ in Euclidean space.

This problem has various important applications in both theory and practice. In many tasks, the data points are drawn from a high dimensional space, however, computations on high-dimensional data are usually hard due to the infamous "curse of dimensionality". The computational tasks can be greatly eased if we can project the data points onto a space of low dimension while the pairwise relations between the points are approximately preserved.

### Johnson-Lindenstrauss Theorem

The Johnson-Lindenstrauss Theorem states that it is possible to project ${\displaystyle n}$ points in a space of arbitrarily high dimension onto an ${\displaystyle O(\log n)}$-dimensional space, such that the pairwise distances between the points are approximately preserved.

 Johnson-Lindenstrauss Theorem For any ${\displaystyle 0<\epsilon <1}$ and any positive integer ${\displaystyle n}$, let ${\displaystyle k}$ be a positive integer such that ${\displaystyle k\geq 4(\epsilon ^{2}/2-\epsilon ^{3}/3)^{-1}\ln n}$ Then for any set ${\displaystyle V}$ of ${\displaystyle n}$ points in ${\displaystyle \mathbf {R} ^{d}}$, there is a map ${\displaystyle f:\mathbf {R} ^{d}\rightarrow \mathbf {R} ^{k}}$ such that for all ${\displaystyle u,v\in V}$, ${\displaystyle (1-\epsilon )\|u-v\|^{2}\leq \|f(u)-f(v)\|^{2}\leq (1+\epsilon )\|u-v\|^{2}}$. Furthermore, this map can be found in expected polynomial time.

### The random projections

The map ${\displaystyle f:\mathbf {R} ^{d}\rightarrow \mathbf {R} ^{k}}$ is done by random projection. There are several ways of applying the random projection. We adopt the one in the original Johnson-Lindenstrauss paper.

 The projection (due to Johnson-Lindenstrauss) Let ${\displaystyle A}$ be a random ${\displaystyle k\times d}$ matrix that projects ${\displaystyle \mathbf {R} ^{d}}$ onto a uniform random k-dimensional subspace. Multiply ${\displaystyle A}$ by a fixed scalar ${\displaystyle {\sqrt {\frac {d}{k}}}}$. For every ${\displaystyle v\in \mathbf {R} ^{d}}$, ${\displaystyle v}$ is mapped to ${\displaystyle {\sqrt {\frac {d}{k}}}Av}$.

The projected point ${\displaystyle {\sqrt {\frac {d}{k}}}Av}$ is a vector in ${\displaystyle \mathbf {R} ^{k}}$.

The purpose of multiplying the scalar ${\displaystyle {\sqrt {\frac {d}{k}}}}$ is to guarantee that ${\displaystyle \mathbf {E} \left[\left\|{\sqrt {\frac {d}{k}}}Av\right\|^{2}\right]=\|v\|^{2}}$.

Besides the uniform random subspace, there are other choices of random projections known to have good performances, including:

• A matrix whose entries follow i.i.d. normal distributions. (Due to Indyk-Motwani)
• A matrix whose entries are i.i.d. ${\displaystyle \pm 1}$. (Due to Achlioptas)

In both cases, the matrix is also multiplied by a fixed scalar for normalization.

### A proof of the Theorem

We present a proof due to Dasgupta-Gupta, which is much simpler than the original proof of Johnson-Lindenstrauss. The proof is for the projection onto uniform random subspace. The idea of the proof is outlined as follows:

1. To bound the distortions to pairwise distances, it is sufficient to bound the distortions to the length of unit vectors.
2. A uniform random subspace of a fixed unit vector is identically distributed as a fixed subspace of a uniform random unit vector. We can fix the subspace as the first k coordinates of the vector, thus it is sufficient to bound the length (norm) of the first k coordinates of a uniform random unit vector.
3. Prove that for a uniform random unit vector, the length of its first k coordinates is concentrated to the expectation.

#### From pairwise distances to norms of unit vectors

Let ${\displaystyle w\in \mathbf {R} ^{d}}$ be a vector in the original space, the random ${\displaystyle k\times d}$ matrix ${\displaystyle A}$ projects ${\displaystyle w}$ onto a uniformly random k-dimensional subspace of ${\displaystyle \mathbf {R} ^{d}}$. We only need to show that

{\displaystyle {\begin{aligned}\Pr \left[\left\|{\sqrt {\frac {d}{k}}}Aw\right\|^{2}<(1-\epsilon )\|w\|^{2}\right]&\leq {\frac {1}{n^{2}}};\quad {\mbox{and}}\\\Pr \left[\left\|{\sqrt {\frac {d}{k}}}Aw\right\|^{2}>(1+\epsilon )\|w\|^{2}\right]&\leq {\frac {1}{n^{2}}}.\end{aligned}}}

Think of ${\displaystyle w}$ as a ${\displaystyle w=u-v}$ for some ${\displaystyle u,v\in V}$. Then by applying the union bound to all ${\displaystyle {n \choose 2}}$ pairs of the ${\displaystyle n}$ points in ${\displaystyle V}$, the random projection ${\displaystyle A}$ violates the distortion requirement with probability at most

${\displaystyle {n \choose 2}\cdot {\frac {2}{n^{2}}}=1-{\frac {1}{n}},}$

so ${\displaystyle A}$ has the desirable low-distortion with probability at least ${\displaystyle {\frac {1}{n}}}$. Thus, the low-distortion embedding can be found by trying for expected ${\displaystyle n}$ times (recalling the analysis fo geometric distribution).

We can further simplify the problem by normalizing the ${\displaystyle w}$. Note that for nonzero ${\displaystyle w}$'s, the statement that

${\displaystyle (1-\epsilon )\|w\|^{2}\leq \left\|{\sqrt {\frac {d}{k}}}Aw\right\|^{2}\leq (1+\epsilon )\|w\|^{2}}$

is equivalent to that

${\displaystyle (1-\epsilon ){\frac {k}{d}}\leq \left\|A\left({\frac {w}{\|w\|}}\right)\right\|^{2}\leq (1+\epsilon ){\frac {k}{d}}.}$

Thus, we only need to bound the distortions for the unit vectors, i.e. the vectors ${\displaystyle w\in \mathbf {R} ^{d}}$ that ${\displaystyle \|w\|=1}$. The rest of the proof is to prove the following lemma for the unit vector in ${\displaystyle \mathbf {R} ^{d}}$.

 Lemma 3.1 For any unit vector ${\displaystyle w\in \mathbf {R} ^{d}}$, it holds that ${\displaystyle \Pr \left[\|Aw\|^{2}<(1-\epsilon ){\frac {k}{d}}\right]\leq {\frac {1}{n^{2}}};}$ ${\displaystyle \Pr \left[\|Aw\|^{2}>(1+\epsilon ){\frac {k}{d}}\right]\leq {\frac {1}{n^{2}}}.}$

As we argued above, this lemma implies the Johnson-Lindenstrauss Theorem.

#### Random projection of fixed unit vector ${\displaystyle \equiv }$ fixed projection of random unit vector

Let ${\displaystyle w\in \mathbf {R} ^{d}}$ be a fixed unit vector in ${\displaystyle \mathbf {R} ^{d}}$. Let ${\displaystyle A}$ be a random matrix which projects the points in ${\displaystyle \mathbf {R} ^{d}}$ onto a uniformly random ${\displaystyle k}$-dimensional subspace of ${\displaystyle \mathbf {R} ^{d}}$.

Let ${\displaystyle Y\in \mathbf {R} ^{d}}$ be a uniformly random unit vector in ${\displaystyle \mathbf {R} ^{d}}$. Let ${\displaystyle B}$ be such a fixed matrix which extracts the first ${\displaystyle k}$ coordinates of the vectors in ${\displaystyle \mathbf {R} ^{d}}$, i.e. for any ${\displaystyle Y=(Y_{1},Y_{2},\ldots ,Y_{n})}$, ${\displaystyle BY=(Y_{1},Y_{2},\ldots ,Y_{k})}$.

In other words, ${\displaystyle Aw}$ is a random projection of a fixed unit vector; and ${\displaystyle BY}$ is a fixed projection of a uniformly random unit vector.

A key observation is that:

 Observation The distribution of ${\displaystyle \|Aw\|}$ is the same as the distribution of ${\displaystyle \|BY\|}$.

The proof of this observation is omitted here.

With this observation, it is sufficient to work on the subspace of the first ${\displaystyle k}$ coordinates of the uniformly random unit vector ${\displaystyle Y\in \mathbf {R} ^{d}}$. Our task is now reduced to the following lemma.

 Lemma 3.2 Let ${\displaystyle Y=(Y_{1},Y_{2},\ldots ,Y_{n})}$ be a uniformly random unit vector in ${\displaystyle \mathbf {R} ^{d}}$. Let ${\displaystyle Z=(Y_{1},Y_{2},\ldots ,Y_{k})}$ be the projection of ${\displaystyle Y}$ to the subspace of the first ${\displaystyle k}$-coordinates of ${\displaystyle \mathbf {R} ^{d}}$. Then ${\displaystyle \Pr \left[\|Z\|^{2}<(1-\epsilon ){\frac {k}{d}}\right]\leq {\frac {1}{n^{2}}};}$ ${\displaystyle \Pr \left[\|Z\|^{2}>(1+\epsilon ){\frac {k}{d}}\right]\leq {\frac {1}{n^{2}}}.}$

Due to the above observation, Lemma 3.2 implies Lemma 3.1 and thus proves the Johnson-Lindenstrauss theorem.

Note that ${\displaystyle \|Z\|^{2}=\sum _{i=1}^{k}Y_{i}^{2}}$. Due to the linearity of expectations,

${\displaystyle \mathbf {E} [\|Z\|^{2}]=\sum _{i=1}^{k}\mathbf {E} [Y_{i}^{2}]}$.

Since ${\displaystyle Y}$ is a uniform random unit vector, it holds that ${\displaystyle \sum _{i=1}^{n}Y_{i}^{2}=\|Y\|^{2}=1}$. And due to the symmetry, all ${\displaystyle \mathbf {E} [Y_{i}^{2}]}$'s are equal. Thus, ${\displaystyle \mathbf {E} [Y_{i}^{2}]={\frac {1}{n}}}$ for all ${\displaystyle i}$. Therefore,

${\displaystyle \mathbf {E} [\|Z\|^{2}]=\sum _{i=1}^{k}\mathbf {E} [Y_{i}^{2}]={\frac {k}{n}}}$.

Lemma 3.2 actually states that ${\displaystyle \|Z\|^{2}}$ is well-concentrated to its expectation.

#### Concentration of the norm of the first ${\displaystyle k}$ entries of uniform random unit vector

We now prove Lemma 3.2. Specifically, we will prove the ${\displaystyle (1-\epsilon )}$ direction:

${\displaystyle \Pr[\|Z\|^{2}<(1-\epsilon ){\frac {k}{d}}]\leq {\frac {1}{n^{2}}}}$.

The ${\displaystyle (1+\epsilon )}$ direction is proved with the same argument.

Due to the discussion in the last section, this can be interpreted as a concentration bound for ${\displaystyle \|Z\|^{2}}$, which is a sum of ${\displaystyle Y_{1}^{2},Y_{2}^{2},\ldots ,Y_{k}^{2}}$. This hints us to use Chernoff-like bounds. However, for uniformly random unit vector ${\displaystyle Y}$, ${\displaystyle Y_{i}}$'s are not independent (because of the constraint that ${\displaystyle \|Y\|=1}$). We overcome this by generating uniform unit vectors from independent normal distributions.

The following is a very useful fact regarding the generation of uniform unit vectors.

 Generating uniform unit vector Let ${\displaystyle X_{1},X_{2},\ldots ,X_{d}}$ be i.i.d. random variables, each drawn from the normal distribution ${\displaystyle N(0,1)}$. Let ${\displaystyle X=(X_{1},X_{2},\ldots ,X_{d})}$. Then ${\displaystyle Y={\frac {1}{\|X\|}}X}$ is a uniformly random unit vector.

Then for ${\displaystyle Z=(Y_{1},Y_{2},\ldots ,Z_{k})}$,

${\displaystyle \|Z\|^{2}=Y_{1}^{2}+Y_{2}^{2}+\cdots +Y_{k}^{2}={\frac {X_{1}^{2}}{\|X\|^{2}}}+{\frac {X_{2}^{2}}{\|X\|^{2}}}+\cdots +{\frac {X_{k}^{2}}{\|X\|^{2}}}={\frac {X_{1}^{2}+X_{2}^{2}+\cdots +X_{k}^{2}}{X_{1}^{2}+X_{2}^{2}+\cdots +X_{d}^{2}}}}$.

To avoid writing a lot of ${\displaystyle (1-\epsilon )}$'s. We write ${\displaystyle \beta =(1-\epsilon )}$. The first inequality (the lower tail) of Lemma 3.2 can be written as:

{\displaystyle {\begin{aligned}\Pr \left[\|Z\|^{2}<{\frac {\beta k}{d}}\right]&=\Pr \left[{\frac {X_{1}^{2}+X_{2}^{2}+\cdots +X_{k}^{2}}{X_{1}^{2}+X_{2}^{2}+\cdots +X_{d}^{2}}}<{\frac {\beta k}{d}}\right]\\&=\Pr \left[d(X_{1}^{2}+X_{2}^{2}+\cdots +X_{k}^{2})<\beta k(X_{1}^{2}+X_{2}^{2}+\cdots +X_{d}^{2})\right]\\&=\Pr \left[(\beta k-d)\sum _{i=1}^{k}X_{i}^{2}+\beta k\sum _{i=k+1}^{d}X_{i}^{2}>0\right].&\qquad (**)\end{aligned}}}

The probability is a tail probability of the sum of ${\displaystyle d}$ independent variables. The ${\displaystyle X_{i}^{2}}$'s are not 0-1 variables, thus we cannot directly apply the Chernoff bounds. However, the following two key ingredients of the Chernoff bounds are satisfiable for the above sum:

• The ${\displaystyle X_{i}^{2}}$'s are independent.
• Because ${\displaystyle X_{i}^{2}}$'s are normal, it is known that the moment generating functions for ${\displaystyle X_{i}^{2}}$'s can be computed as follows:
 Fact 3.3 If ${\displaystyle X}$ follows the normal distribution ${\displaystyle N(0,1)}$, then ${\displaystyle \mathbf {E} \left[e^{\lambda X^{2}}\right]=(1-2\lambda )^{-{\frac {1}{2}}}}$, for ${\displaystyle \lambda \in \left(-\infty ,1/2\right)}$

Therefore, we can re-apply the technique of the Chernoff bound (applying Markov's inequality to the moment generating function and optimizing the parameter ${\displaystyle \lambda }$) to bound the probability ${\displaystyle (**)}$:

{\displaystyle {\begin{aligned}&\quad \,\Pr \left[(\beta k-d)\sum _{i=1}^{k}X_{i}^{2}+\beta k\sum _{i=k+1}^{d}X_{i}^{2}>0\right]\\&=\Pr \left[\exp \left\{(\beta k-d)\sum _{i=1}^{k}X_{i}^{2}+\beta k\sum _{i=k+1}^{d}X_{i}^{2}\right\}>1\right]\\&=\Pr \left[\exp \left\{\lambda \left((\beta k-d)\sum _{i=1}^{k}X_{i}^{2}+\beta k\sum _{i=k+1}^{d}X_{i}^{2}\right)\right\}>1\right]&\quad ({\text{for }}\lambda >0)\\&\leq \mathbf {E} \left[\exp \left\{\lambda \left((\beta k-d)\sum _{i=1}^{k}X_{i}^{2}+\beta k\sum _{i=k+1}^{d}X_{i}^{2}\right)\right\}\right]&\quad {\text{(by Markov inequality)}}\\&=\prod _{i=1}^{k}\mathbf {E} \left[e^{\lambda (\beta k-d)X_{i}^{2}}\right]\cdot \prod _{i=k+1}^{d}\mathbf {E} \left[e^{\lambda \beta kX_{i}^{2}}\right]&\quad ({\text{independence of }}X_{i})\\&=\mathbf {E} \left[e^{\lambda (\beta k-d)X_{1}^{2}}\right]^{k}\cdot \mathbf {E} \left[e^{\lambda \beta kX_{1}^{2}}\right]^{d-k}&\quad {\text{(symmetry)}}\\&=(1-2\lambda (\beta k-d))^{-{\frac {k}{2}}}(1-2\lambda \beta k)^{-{\frac {d-k}{2}}}&\quad {\text{(by Fact 3.3)}}\end{aligned}}}

The last term ${\displaystyle (1-2\lambda (\beta k-d))^{-{\frac {k}{2}}}(1-2\lambda \beta k)^{-{\frac {d-k}{2}}}}$ is minimized when

${\displaystyle \lambda ={\frac {1-\beta }{2\beta (d-k\beta )}},}$

so that

{\displaystyle {\begin{aligned}&\quad \,(1-2\lambda (\beta k-d))^{-{\frac {k}{2}}}(1-2\lambda \beta k)^{-{\frac {d-k}{2}}}\\&=\beta ^{\frac {k}{2}}\left(1+{\frac {(1-\beta )k}{(d-k)}}\right)^{\frac {d-k}{2}}\\&\leq \exp \left({\frac {k}{2}}(1-\beta +\ln \beta )\right)&\qquad ({\text{since }}\left(1+{\frac {(1-\beta )k}{(d-k)}}\right)^{\frac {d-k}{(1-\beta )k}}\leq e)\\&=\exp \left({\frac {k}{2}}(\epsilon +\ln(1-\epsilon ))\right)&\qquad (\beta =1-\epsilon )\\&\leq \exp \left(-{\frac {k\epsilon ^{2}}{4}}\right)&\qquad ({\text{by Taylor expansion }}\ln(1-\epsilon )\leq -\epsilon -{\frac {\epsilon ^{2}}{2}}),\end{aligned}}}

which is is ${\displaystyle \leq {\frac {1}{n^{2}}}}$ for the choice of k in the Johnson-Lindenstrauss theorem that

${\displaystyle k\geq 4(\epsilon ^{2}/2-\epsilon ^{3}/3)^{-1}\ln n}$.

So we have proved that

${\displaystyle \Pr[\|Z\|^{2}<(1-\epsilon ){\frac {k}{d}}]\leq {\frac {1}{n^{2}}}}$.

With the same argument, the other direction can be proved so that

${\displaystyle \Pr[\|Z\|^{2}>(1+\epsilon ){\frac {k}{d}}]\leq \exp \left({\frac {k}{2}}(-\epsilon +\ln(1+\epsilon ))\right)\leq \exp \left(-{\frac {k(\epsilon ^{2}/2-\epsilon ^{3}/3)}{2}}\right)}$,

which is also ${\displaystyle \leq {\frac {1}{n^{2}}}}$ for ${\displaystyle k\geq 4(\epsilon ^{2}/2-\epsilon ^{3}/3)^{-1}\ln n}$.

Lemma 3.2 is proved. As we discussed in the previous sections, Lemma 3.2 implies Lemma 3.1, which implies the Johnson-Lindenstrauss theorem.