# Rain droplets falling on a table

Suppose you have a circular table of radius $R$. This table has been left outside, and it begins to rain at a constant rate of one droplet per second. The drops, which can be considered points as they fall, can only land in such a way such that they impact the surface of the table. Once they strike the table, they form a puddle of radius $r$, centered at their point of impact. What is the expected number of droplets it takes to cover the table in water?

The answer should be left in terms of $R$ and $r$. However, if you can simulate this, while changing both $r$ and $R$ so that some regression might be applied to find the approximate relation, that would be nice as well. I'd really like some intuition as to how the two are related.

I have tried decomposing the problem by considering only the 1-dimensional case with line segments, but even its solution has eluded me. A potential starting point could be the discrete case of marbles falling into buckets.

The following edit was suggested by Jbeuh:

A more formal restatement of the problem :

Consider a sequence $X_1,\ldots,X_n$ of independent random variables following a uniform distribution on a disk $D$ of radius $R$. For each $i$, let $C_i$ be the disk centered at $X_i$ with radius $r$. Let $Y$ be the first $i$ such that the disks $C_1,\ldots,C_i$ forms a cover of $D$. What is the expected value of $Y$?

-
Cross-posted on MO – Ilya Jul 29 '12 at 8:17
I don't understand the problem the way it is expressed. You seem to be treating this like a packing problem. But if there is some form of randomness to how the droplets strike the table that is left unstated and would change this into a statistics problem. The statistics problems seems to be indicated by the use of the term expected number rather than minimum number. But I don't see the question as being well defined unless I am missing an implicit assumption. – Michael Chernick Jul 29 '12 at 13:59
@Michael: I think there's an implicit assumption that the positions of the raindrops form a sequence of independent identically distributed random variables, with the distribution being uniform over the table's area. – Henning Makholm Jul 29 '12 at 14:47
@Henning: That is correct. I apologize for not stating it explicitly. – Nicolás Kim Jul 29 '12 at 15:01
This isn't an answer because it applies non-mathematical reasoning. But if this was a bowl question, I would guess the expected number is (R/r)^2 -- that is, the ratio of the areas of the big circle to the little one -- because what else is there? – Jeremy Teitelbaum Jul 29 '12 at 19:13

There's a nice approach in Coverage by Randomly Deployed Wireless Sensor Networks by Wan and Yi that allows us to get an expansion in $\mu:=R/r$ for the expected number of raindrops required.

The basic idea is to focus on the intersections among the circles. Since any uncovered area must be bounded by arcs bounded by intersections that aren't covered by other disks, the entire table is covered if and only if there is at least one intersection and there is no uncovered intersection. Here intersections include intersections between raindrop circles and the table circle.

First consider the probability of there being at least one intersection, uncovered or not, between a raindrop circle and the table circle. The centre of the raindrop must lie within $r$ of the table circle, and the probability for that is $1-\pi(R-r)^2/(\pi R^2)=2\mu^{-1}\left(1+O\left(\mu^{-1}\right)\right)$. Since we need at least $\mu^2$ drops to cover the table, the probability that none of them intersects the table circle goes to zero. Thus, asymptotically the probability that the table is covered becomes the probability that there are no uncovered intersections.

Since the probability for a raindrop circle to intersect the table circle is $2\mu^{-1}\left(1+O\left(\mu^{-1}\right)\right)$, the expected number of intersections between a raindrop circle and the table circle is $2n\mu^{-1}\left(1+O\left(\mu^{-1}\right)\right)$, where $n$ is the number of drops. Each of these can be covered by any of the remaining $n-1$ disks, with probability $\mu^{-2}$ each (neglecting border effects), so the expected number of uncovered intersections of this type is $2n\mu^{-1}\left(1-\mu^{-2}\right)^{n-1}\left(1+O\left(\mu^{-1}\right)\right)$. For two raindrop circles to intersect, their centres have to be at most $2r$ apart, and (again neglecting border effects) the probability for this is $\pi(2r)^2/\pi R^2=4\mu^{-2}$. Thus the expected number of intersections among $n$ raindrop circles is $4n(n-1)\mu^{-2}$ (since there are $n(n-1)/2$ pairs and each intersecting pair contributes $2$ intersections). Again, each of these can be covered by any of the remaining $n-2$ disks, with probability $\mu^{-2}$ each, so the expected number of uncovered intersections of this type is $I(n)=4n(n-1)\mu^{-2}\left(1-\mu^{-2}\right)^{n-2}$. Since $n\ge\mu^2$, this dominates the contribution from intersections with the table circle by a factor of $\mu$, so we can neglect intersections with the table circle if we only want the leading terms of the expansion; this is the same level of approximation as the one applied in taking the area fraction covered by a raindrop to be $\mu^{-2}$ and neglecting border effects.

To that approximation, $I(n)$ is an upper bound for the probability that at least one intersection, and thus some part of the table, is uncovered. At $n=\mu^2$, this is approximately $(4/\mathrm e)\mu^2$, and thus greater than $1$ for sufficiently large $\mu$. Since $n\ge\mu^2$, we can safely replace the upper bound by $1$ up to $\mu^2$, and then also up to the point $n_0$ where $I(n)$ falls below $1$ again.

Since $n\ge\mu^2$, we can approximate $n-1$ and $n-2$ by $n$ and obtain $n_0$ as the greater of the two real solutions of the resulting equation $4n^2\mu^{-2}\left(1-\mu^{-2}\right)^n=1$:

$$n_0\approx\frac{2W_{-1}\left(\mu\log\left(1-\mu^{-2}\right)/4\right)}{\log\left(1-\mu^{-2}\right)}\;,$$

where $W_{-1}$ is the lower branch of the Lambert W function.

Now the expected number of drops required to cover the table is

\begin{align} \langle N\rangle &= \sum_{k=0}^\infty kP(N=k) \\ &= \sum_{k=0}^\infty P(N\gt k) \\ &\lesssim \sum_{k=0}^\infty\min(1,I(k)) \\ &\le n_0+\sum_{k=\lfloor n_0\rfloor}^\infty I(k)\;. \end{align}

We can approximate the remaining sum by an integral:

\begin{align} \sum_{k=\lfloor n_0\rfloor}^\infty I(k) &\approx \int_{n_0}^\infty \left.4\mu^{-2}\frac{\partial^2}{\partial q^2}q^k\right|_{q=1-\mu^{-2}}\,\mathrm dk \\ &= -\left.4\mu^{-2}\frac{\partial^2}{\partial q^2}\frac{q^{n_0}}{\log q}\right|_{q=1-\mu^{-2}} \\ &= -\left.4\mu^{-2}n_0(n_0-1)\frac{q^{n_0-2}}{\log q}\right|_{q=1-\mu^{-2}}\left(1+O\left(\mu^{-2}\right)\right) \\ &= -\frac1{\log\left(1-\mu^{-2}\right)}\left(1+O\left(\mu^{-2}\right)\right) \\ &= \mu^2+O(1)\;. \end{align}

Now we can use the asymptotic expansion of $W_{-1}$,

$$W_{-1}(x)=\log(-x)-\log(-\log(-x))+\frac{\log(-\log(-x))}{\log(-x)}+O\left(\left(\frac{\log(-\log(-x))}{\log(-x)}\right)^2\right)\;,$$

to get an expansion for $\langle N\rangle$. If we want only the terms up to $O\left(\mu^2\right)$ we can replace $\log\left(1-\mu^{-2}\right)$ by $-\mu^{-2}$ in both instances to obtain

\begin{align} n_0 &\approx -2\mu^2W_{-1}\left(-\frac1{4\mu}\right) \\ &= 2\mu^2\left(\log(4\mu)+\log(\log(4\mu))+\frac{\log\log(4\mu)}{\log(4\mu)}+O\left(\left(\frac{\log\log\mu}{\log\mu}\right)^2\right)\right)\;. \end{align}

Then adding the term from the remaining sum yields

$$\langle N\rangle\lesssim2\mu^2\left(\log(4\mu)+\log(\log(4\mu))+\frac12+\frac{\log\log(4\mu)}{\log(4\mu)}+O\left(\left(\frac{\log\log\mu}{\log\mu}\right)^2\right)\right)\;,$$

where the $\lesssim$ and the big $O$ should be taken with a grain of salt, since I analyzed neither the error from replacing $n-1$ and $n-2$ by $n$, nor the one from approximating the sum by an integral, nor whether the upper bound from the first moment method is asymptotic. Perhaps someone more rigorous-minded than I can fill in some of the gaps.

I did some exact (i.e. non-discretized) simulations; the results are in good agreement with the above expansion. The code is here. I ran $1000$ trials each for $1/20\le\mu^{-1}\le1$ in steps of $1/100$.

Here's a log-log plot of $\langle N\rangle$ over $\mu$:

(You can get the full resolution by displaying the image in another tab or window.) The red crosses are the data points, and the green, blue, magenta and cyan curves respectively include successive terms of the above expansion. The fact that successive terms get increasingly close to the data seems to indicate that the unanalyzed errors are at most $O(\mu^2)$.

The estimated standard errors for the data points from the simulation are too small to display. The values and errors at different $\mu$ are strongly correlated, since the code works by successively adding raindrop centres and lowering a threshold $r$ at which drops at these centres would cover the table; but the trial runs as a whole are independent, so the error estimates are valid.

A few words about the code: It recursively subdivides the square containing the unit circle; for each square, it computes three thresholds for $r$: the least $r$ for which the entire square would be dry, the least $r$ for which the square would be partially covered by more than one drop, and the least $r$ for which the entire square would be wet. These thresholds divide the $r$ values into four ranges; in the first two, the square is known not to be fully covered, in the last one it is known to be fully covered, and in between (if there is more than one drop partially covering it) the recursion has to descend to the next level to decide. Raindrops fall one after the other, and after each drop the statistics for the average and the variance estimate are collected for the radii up to which the table is fully covered. Of course there are some complications, such as dealing with squares on the border of the table.

Disclaimer: This sort of code is difficult to fully debug – I did some testing with known configurations and I hope that I caught all the bugs, and the agreement with the analytic expansion is reassuring, but there's no guarantee that some cases aren't perhaps being treated incorrectly.

[Update:]

Since mjqxxxx elegantly proved that the expected number $\langle N\rangle$ of drops is bounded from below by $2\mu^2\log\mu(1+o(1))$, I thought it's worthwhile to make at least the part of my argument fully rigorous that shows that $\langle N\rangle$ is also bounded from above by $2\mu^2\log\mu(1+o(1))$, since together these imply $\langle N\rangle\sim2\mu^2\log\mu$.

So consider again the intersections among circles. Since we will be bounding the probability of the table not being fully covered by its maximal value $1$ for $n\lt\mu^2$, we can disregard the possibility of there being no intersections at all, since this is impossible for $n\ge\mu^2$. Thus we only need to consider the probability of there being an uncovered intersection. As shown above, this is asympotically dominated by the probability of there being an uncovered intersection between raindrop circles, which is $4n(n-1)\mu^{-2}\left(1-\mu^{-2}\right)^{n-2}(1+o(1))$ (where the $o(1)$ term accounts for border effects in the area fractions $\mu^{-2}$ and $4\mu^{-2}$). We can bound this from above by

$$4n^2\mu^{-2}\left(1-\mu^{-2}\right)^n\left(1-\mu^{-2}\right)^{-2}(1+o(1))=4n^2\mu^{-2}\left(1-\mu^{-2}\right)^n(1+o(1))\;.$$

From the solution for $4n^2\mu^{-2}\left(1-\mu^{-2}\right)^n=1$ above in terms of $W_{-1}$ and its asymptotic expansion, we know that we can choose an integer $n_0=2\mu^2\log\mu(1+o(1))$ such that this bound is $1+o(1)$. Then we can bound the probability of the table not being fully covered by $1$ for $n\le n_0$ and by the above bound for $n\gt n_0$. This gives a contribution $n_0$ to the expected number of disks from $n\le n_0$, which has the right asymptotic behaviour, so we only need to show that the contribution from $n\gt n_0$ is $o\left(\mu^2\log\mu\right)$. To that end, take the logarithm, bound it linearly using $\log n\le\log n_0+(n-n_0)/n_0$, and sum the resulting geometric series:

\begin{align} &\log\left(4n^2\mu^{-2}\left(1-\mu^{-2}\right)^n(1+o(1))\right) \\ =& \log\left(4\mu^{-2}\right)+2\log n+n\log\left(1-\mu^{-2}\right)+o(1) \\ \le& \log\left(4\mu^{-2}\right)+2\log n_0+2(n-n_0)/n_0+n\log\left(1-\mu^{-2}\right)+o(1) \\ =& (n-n_0)\left(2/n_0+\log\left(1-\mu^{-2}\right)\right)+o(1)\;, \end{align}

\begin{align} &\sum_{n=n_0}^\infty\left(4n^2\mu^{-2}\left(1-\mu^{-2}\right)^n\left(1+o(1)\right)\right) \\ \le& \sum_{n=n_0}^\infty\exp\left((n-n_0)\left(2/n_0+\log\left(1-\mu^{-2}\right)\right)+o(1)\right) \\ =& \frac1{1-\exp\left(2/n_0+\log\left(1-\mu^{-2}\right)\right)}(1+o(1)) \\ =& \frac1{1-\left(1-\mu^{-2}\right)\exp\left(2/n_0\right)}(1+o(1)) \\ =& \frac1{1-\left(1-\mu^{-2}\right)\left(1+o\left(\mu^{-2}\right)\right)}(1+o(1)) \\ =& \mu^2(1+o(1))\;. \end{align}

Thus $\langle N\rangle$ is bounded from above by $2\mu^2\log\mu(1+o(1))$, and together with mjqxxxx' result it follows that $\langle N\rangle\sim2\mu^2\log\mu$.

P.S.: Note that neither mjqxxxx' argument nor mine depends on the shapes of the drops or the table (as regards the leading term, not the corrections derived above). Thus we can conclude generally that the expected number of objects with area a fraction $\lambda$ of the table area that are required to cover the entire table is asymptotic to $\lambda\log\lambda$.

-
+1 Wow! Very nice! – Sasha Aug 7 '12 at 16:55
+1, Really salute to your efforts in posting such a lengthy answer. – Iyengar Aug 7 '12 at 17:54
@Sasha and Iyengar: Thanks! I updated the answer with a more rigorous proof for the leading asymptotic term. – joriki Aug 7 '12 at 23:05
I think you've really hit this question out of the ballpark. What a great answer! Thank you very much joriki! I just got out of bed but once I've had my tea I will go through your response more thoroughly. – Nicolás Kim Aug 8 '12 at 12:31
@Nicolás: You're welcome! Glad you like it :-) – joriki Aug 9 '12 at 6:07

Allow me to make some discretization approximations to a circle. Define a circle of radius $r$ at location $\bf x$ as the set of all points $\bf y$ on a lattice in $\mathbb{Z}_d$ where $\|{\bf x}-{\bf y}\|_2<r$. This isn't to bad when $r \gg 1$, shown below is a 100 radius "circle":

The approximation gets worse when $r<10$, so we will limit all droplets to this size. To code up a simple Monte Carlo example we make a square area $A$ whose length is $2R + 2r$, and put a circular table in the center of radius $R$ with a positive mask. Choose points in $A$ and keep them if they are in within the radius $R$. For each selected point, subtract a circular mask of radius $r$. Continue until the circular table is empty and count the drops needed. An example of this in motion looks like:

A time-series of the log of the area remaining for an individual run:

I ran 10 trials for $r \in 10..R-1$ and plotted the mean with the std dev as the error bar.

I'm at a loss to describe the function - the best fit I could come up with (which really is not fit at all) was $c \exp{(-17.9 (r/R)^{-1.6})}$. At the very least, I can say that it drops faster than an exponential.

For posterity and completeness, the code I wrote is below. Note that you can generalize to $d$ dimensions!

from numpy import *

for idx in ndindex(A.shape):
coord = array(idx) - radius # recenter
r     = dot(coord, coord)
A[idx] = r
B = zeros(A.shape,dtype=bool)
return B

def spot_on_table(dimension):
table_r_squared = table_r ** 2
r2 = table_r_squared+1
max_dim = 2*table_r
while r2 > table_r_squared:
pt = random.randint(-max_dim,max_dim,dimension)
r2  = dot(pt,pt)
return pt

r = droplet.shape[0]/2
center = array(table.shape[0])/2
idx = [slice(center-r+x, center+r+1+x) for x in loc]
idx = tuple(idx)

else  : table[idx] *= ~droplet

def raindrop_question(dimension, droplet_r, table_r):
random.seed()
buff = droplet_r

# Create the table
table = zeros((2*table_r+1+2*buff,)*dimension)

# Let it rain!
counter = 0
while table.any():
raindrop(table,circle(droplet_r,dimension), spot_on_table(dimension))
counter += 1

return (dimension, droplet_r, table_r), counter

def CB(sol):
print sol

import multiprocessing, itertools

dimension = 2
table_r   = 100
droplet_r = arange(10,table_r)

P = multiprocessing.Pool(16)

for r in droplet_r:
for n in xrange(10):
sol = P.apply_async(raindrop_question, (dimension, r, table_r),
callback=CB)
P.close()
P.join()

-
FWIW, it seems that a function of the form $f(r/R) = c \cdot (r/R)^{-2}$ fits your simulation of "drops needed" quite well, with $c \approx 12$ (whereas the lower bound I posted has the same form but with $c = 2 \pi / \sqrt{27} \approx 1.2$. – r.e.s. Aug 3 '12 at 0:47
As r.e.s. says, it seems to be consistent with the other results, and this result really verifies that we're on the right track. Thank you, Hooked! – Nicolás Kim Aug 3 '12 at 10:33

For any covering of the target region with shapes of diameter $\le r$, if one droplet center lies within each shape, this is sufficient to cover the entire region with droplets. This can be used to calculate an upper bound on the expected time to cover the table. Note that this upper bound will be tighter when the number of shapes is smaller; i.e., we want the area of each shape to be as large as possible. Suppose the covering uses regular hexagons of diameter $r$: these have area $3r^2\sqrt{3}/8$, so there will be about $$N_{\rm hex} = \frac{8\pi}{3\sqrt{3}}\left(\frac{R}{r}\right)^2$$ of them. The coupon collector's problem then states that the expected time to hit all the hexagons is $E[T_{\rm hex}] \sim N_{\rm hex}\ln N_{\rm hex}$.

On the other hand, for any packing of the target region with disks of radius $r$, it is necessary for at least one droplet center to fall within each disk in order for the target region to be covered (in particular, the disk centers cannot be covered otherwise). This can be used to provide a lower bound on the expected time. Here we again use a hexagonal packing, which covers a fraction $\pi/\sqrt{12}$ of the table's surface, but now the hexagon area is $2r^2\sqrt{3}$. The number of disks is then $$N_{\rm disc}=\frac{\pi}{2\sqrt{3}}\left(\frac{R}{r}\right)^2=\frac{3}{16}N_{\rm hex}.$$ The coupon collector's problem in this case states that the expected time to hit all the disks is $E[T_{\rm disc}] \sim \frac{\sqrt{12}}{\pi}N_{\rm disc}\ln N_{\rm disc}=\left(\frac{R}{r}\right)^{2}\ln N_{\rm disc}$. Note the extra factor of $\sqrt{12}/\pi$, which comes from the fact that each droplet only "collects a coupon" with probability $\pi/\sqrt{12}$.

Putting these bounds together, we have that the expected time to cover the table satisfies $$2 \mu^2 \ln \mu + O(\mu^2) = E[T_{\rm disc}] \le E[T] \le E[T_{\rm hex}] = \frac{16\pi}{3\sqrt{3}} \mu^2 \ln \mu + O(\mu^2)$$ for $\mu \equiv (R/r) \gg 1$. In particular, the expected time is proven to be $\Theta(\mu^2 \ln \mu)$, with a multiplicative factor bounded between $2$ and about $9.68$.

-
This is a nice improvement over the result in the MO thread, which obtains coarser bounds of $\pi/4$ and $2\pi$ using a square lattice. In both cases, the actual coefficient $2$ is close to the geometric mean of the two bounds. – joriki Aug 7 '12 at 16:49
@joriki: Actually the lower bound is $2 (R/r)^2 \ln (R/r)$... there's a factor of $2$ from the logarithm of the square. – mjqxxxx Aug 7 '12 at 17:01
I see -- I was confused by the fact that you used the same variable name for the square of the ratio as I used for the ratio :-) This is quite interesting -- so the lower bound doesn't actually depend on the density of the packing -- any arbitrarily sparse arrangement of disks that covers a fixed fraction of the table will do. Now I see what fedja may have meant at MO about the correct factor $2$ coming out of such an argument. – joriki Aug 7 '12 at 17:42
@joriki: That's right. The lower bound depends on the number of disks in the arrangement only logarithmically, so the packing density doesn't affect the constant in front (once you're covering a fixed fraction of the table). – mjqxxxx Aug 7 '12 at 17:59
@joriki: I edited my answer to use the same $\mu$ for easier comparison. – mjqxxxx Aug 7 '12 at 18:48

A crude lower bound is given by

$E(Y) \gt \frac{2 \pi}{\sqrt{27}} (\frac{R}{r})^2$.

This follows by first considering the placement of radius-$r$ disks non-randomly to cover the larger radius-$R$ disk. According to a paper by G. F. Tóth (p. 260), the number of radius-$r$ disks needed to do this is greater than $m = \frac{2 \pi}{\sqrt{27}} (\frac{R}{r})^2$; consequently, random placement of these disks can attain total coverage only if there are more than $m$ of them, implying $Y \gt m$, and hence $E(Y) \gt m$.

-
That's a very interesting paper! Thank you for your response, "crude" as it may be! – Nicolás Kim Aug 2 '12 at 15:17