Skip to content

Commit 5a2e349

Browse files
authored
Update nearest_points.md - avoid \coloneqq and add links
1 parent c2eba24 commit 5a2e349

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/geometry/nearest_points.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ Now we need to decide on how to set $d$ so that it minimizes $\Theta(\sum_{i=1}^
183183

184184
We need $d$ to be an approximation of the minimum distance $d$, and the trick is to just sample $n$ distances randomly and choose $d$ to be the smallest of these distances. We now prove that the expected running time is linear.
185185

186-
**Proof.** Imagine the disposition of points in squares with a particular choice of $d$, say $x$. Consider $d$ a random variable, resulting from our sampling of distances. Let's define $C(x) = \sum_{i=1}^{k(x)} n_i(x)^2$ as the cost estimation for a particular disposition when we choose $d=x$. Now, let's define $\lambda(x)$ such that $C(x) = \lambda(x) \, n$. What is the probability that such choice $x$ survives the sampling of $n$ independent distances? If a single pair among the sampled ones has distance smaller than $x$, this arrangement will be replaced by the smaller $d$. Inside a square, at least a quarter of the pairs would raise a smaller distance (imagine four subsquares in every square, and use the pigeonhole principle), so we have $\sum_{i=1}^{k} \frac{1}{4} {n_i \choose 2}$ pairs which yield a smaller final $d$. This is, approximately, $\frac{1}{8} \sum_{i=1}^{k} n_i^2 = \frac{1}{8} \lambda(x) n$. On the other hand, there are about $\frac{1}{2} n^2$ pairs that can be sampled. We have that the probability of sampling a pair with distance smaller than $x$ is at least (approximately)
186+
**Proof.** Imagine the disposition of points in squares with a particular choice of $d$, say $x$. Consider $d$ a random variable, resulting from our sampling of distances. Let's define $C(x) := \sum_{i=1}^{k(x)} n_i(x)^2$ as the cost estimation for a particular disposition when we choose $d=x$. Now, let's define $\lambda(x)$ such that $C(x) = \lambda(x) \, n$. What is the probability that such choice $x$ survives the sampling of $n$ independent distances? If a single pair among the sampled ones has distance smaller than $x$, this arrangement will be replaced by the smaller $d$. Inside a square, at least a quarter of the pairs would raise a smaller distance (imagine four subsquares in every square, and use the pigeonhole principle), so we have $\sum_{i=1}^{k} \frac{1}{4} {n_i \choose 2}$ pairs which yield a smaller final $d$. This is, approximately, $\frac{1}{8} \sum_{i=1}^{k} n_i^2 = \frac{1}{8} \lambda(x) n$. On the other hand, there are about $\frac{1}{2} n^2$ pairs that can be sampled. We have that the probability of sampling a pair with distance smaller than $x$ is at least (approximately)
187187

188188
$$\frac{\lambda(x) n / 8}{n^2 / 2} = \frac{\lambda(x)/4}{n}$$
189189

190190
so the probability of at least one such pair being chosen during the $n$ rounds (and therefore finding a smaller $d$) is
191191

192192
$$1 - \left(1 - \frac{\lambda(x)/4}{n}\right)^n \ge 1 - e^{-\lambda(x)/4}$$
193193

194-
(we have used that $(1 + x)^n \le e^{xn}$ for any real number $x$, check https://en.wikipedia.org/wiki/Bernoulli%27s_inequality#Related_inequalities). <br> Notice this goes to $1$ exponentially as $\lambda(x)$ increases. This hints that $\lambda$ will be small usually.
194+
(we have used that $(1 + x)^n \le e^{xn}$ for any real number $x$, check [this Wikipedia page](https://en.wikipedia.org/wiki/Bernoulli%27s_inequality#Related_inequalities)). <br> Notice this goes to $1$ exponentially as $\lambda(x)$ increases. This hints that $\lambda$ will be small usually.
195195

196196

197197
We have shown that $\Pr(d \le x) \ge 1 - e^{-\lambda(x)/4}$, or equivalently, $\Pr(d \ge x) \le e^{-\lambda(x)/4}$. We need to know $\Pr(\lambda(d) \ge \text{something})$ to be able to estimate its expected value. We notice that $\lambda(d) \ge \lambda(x) \iff d \ge x$. This is because making the squares smaller only reduces the number of points in each square (splits the points into other squares), and this keeps reducing the sum of squares. Therefore,
198198

199199
$$\Pr(\lambda(d) \ge \lambda(x)) = \Pr(d \ge x) \le e^{-\lambda(x)/4} \implies \Pr(\lambda(d) \ge t) \le e^{-t/4} \implies \mathbb{E}[\lambda(d)] \le \int_{0}^{+\infty} e^{-t/4} \, \mathrm{d}t = 4$$
200200

201-
(we have used that $E[X] = \int_0^{+\infty} \Pr(X \ge x) \, \mathrm{d}x$, check https://math.stackexchange.com/a/1690829).
201+
(we have used that $E[X] = \int_0^{+\infty} \Pr(X \ge x) \, \mathrm{d}x$, check [the proof](https://math.stackexchange.com/a/1690829)).
202202

203203
Finally, $\mathbb{E}[C(d)] = \mathbb{E}[\lambda(d) \, n] \le 4n$, and the expected running time is $O(n)$, with a reasonable constant factor. $\quad \blacksquare$
204204

@@ -299,13 +299,13 @@ pair<pt,pt> closest_pair_of_points_rand_reals(vector<pt> P) {
299299
Now we introduce a different randomized algorithm which is less practical but very easy to show that it runs in expected linear time.
300300

301301
- Permute the $n$ points randomly
302-
- Take $\delta \coloneqq \operatorname{dist}(p_1, p_2)$
302+
- Take $\delta := \operatorname{dist}(p_1, p_2)$
303303
- Partition the plane in squares of side $\delta/2$
304304
- For $i = 1,2,\dots,n$:
305305
- Take the square corresponding to $p_i$
306306
- Interate over the $25$ squares within two steps to our square in the grid of squares partitioning the plane
307307
- If some $p_j$ in those squares has $\operatorname{dist}(p_j, p_i) < \delta$, then
308-
- Recompute the partition and squares with $\delta \coloneqq \operatorname{dist}(p_j, p_i)$
308+
- Recompute the partition and squares with $\delta := \operatorname{dist}(p_j, p_i)$
309309
- Store points $p_1, \dots, p_i$ in the corresponding squares
310310
- else, store $p_i$ in the corresponding square
311311
- output $\delta$

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy