I came up with this problem:
If I draw a length 1 line segment randomly, then draw another one, what's the probability that they'll intersect?
More precisely,
Consider a rectangular area of size $w\times l$ with periodic boundary conditions, where $w\ge 2,l\ge 2$. Draw two length 1 line segments randomly. Here, by randomly it means, first choose a random point with uniform distribution over the rectangular area, then from the circle that is centered at the first point with radius one, randomly choose a point with uniform distribution. These two points are the end points of the line segment.
Question: What's the probability that the two line segments intersect?
The solution can be found by simply integrating the probability densities, which gives $p=\frac{1}{A}\times 4\times\frac{1}{2\pi}(p_1+p_2+p_3+p_4)$, where $A=lw$ is the area, and
$p_1=\int_0^1 rdr\int_0^{\frac{\pi}{2}}\theta-\sin^{-1}(r\sin\theta)d\theta$
$p_2=\int_{\frac{1}{2}}^1dx\int_0^\sqrt{1-x^2}\tan^{-1}\frac{x}{y}+\tan^{-1}\frac{1-x}{y}dy$
$\quad=\frac{1}{2}\int_0^1 rdr\int_{\sin^{-1}\frac{r}{2}}^{\frac{\pi}{2}}\theta+\tan^{-1}\frac{1-r\sin\theta}{r\cos\theta}d\theta$
$p_3=\int_0^1 rdr\int_0^{\sin^{-1}\frac{r}{2}}\theta+\cos^{-1}(r\cos\theta)d\theta$
$p_4=\int_0^{\frac{1}{2}}dx\int_\sqrt{1-x^2}^1 2\cos^{-1}y\ dy$
And the results are
$p_1=\frac{1}{4}$
$p_2=0.583664$
$p_3=0.155138$
$p_4=0.011197 =\frac{1}{72}(27 - 3 \sqrt 3 \pi - \pi^2)$
Details can be found on my blog post.
The summation of these numbers is 0.999999, which is probably not a coincidence. My questions are,
- Do they sum up to exactly 1, so that the probability is exactly $\frac{2}{\pi A}$? (Probably true, just need to find the exact integration value.) (✓ Proved)
- Is there an easier and more intuitive way to prove this?
- How can this be generalized?
I searched similar problems but I didn't find anything quite the same.
Considering that Buffon's needle problem has probability $\frac{2l}{\pi t}$, are they somehow related?
A more general description of this problem can be stated as the following:
Assuming there is a random uniform distribution with density $\frac{1}{A}$ of line segments with length 1 on the 2D plane. More precisely, the distribution is, the middle points of the line segments are uniformly distributed on the plane with density $\frac{1}{A}$ and the angles are also uniformly distributed from 0 to $2\pi$.
Then, if we draw another line segment of length one randomly, as described in the beginning, the expected number of intersections between this line segment and the line segments in the "background" is $\frac{2}{\pi A}$.
Edit:
I think, indeed, the Buffon's needle problem can be seen as a special case of this problem.
If we see each line as an infinite chain of length 1 line segments, and the distance between the lines is $t$, then each line segment occupies an area $t$, thus the expectation of the number of intersections between a length 1 needle with the lines is $\frac{2}{\pi A}=\frac{2}{\pi t}$. Due to the linearity of expectation, a length $l$ needle will have expectation $\frac{2l}{\pi t}$. When $l\leq t$, there can be at most one intersection, thus this is the probability of them intersecting.
Update 2023.10.30
After seeing @Claude Leibovici's answer, it seems that the integration of $p_3$ is particularly complicated, so I thought maybe doing it in the other direction is easier.
If we integrate $r$ first instead,the interval of $\theta$ is $[0,\frac{\pi}{6}]$ and the interval of $r$ is $[2\sin\theta,1]$. The integration is
$p_3=\int_0^{\frac{\pi}{6}}d\theta\int_{2\sin\theta}^1 (\theta+\cos^{-1}(r\cos\theta))rdr$ $\quad=\int_0^{\frac{\pi}{6}}\frac{\theta}{2}(1-4\sin^2\theta)+\left[\frac{r^2\cos^2\theta}{2}\cos^{-1}(r\cos\theta)+\frac{1}{4}\sin^{-1}(r\cos\theta)-\frac{r\cos\theta}{4}\sqrt{1-r^2\cos^2\theta}\right]_{2\sin\theta}^1\frac{1}{\cos^2\theta}d\theta$ $\quad=\int_0^{\frac{\pi}{6}}\frac{\theta}{2}(1-4\sin^2\theta)+\left(\theta\frac{\cos^2\theta}{2}+\frac{1}{4}(\frac{\pi}{2}-\theta)-\frac{\sin\theta\cos\theta}{4}-\frac{\sin^2 2\theta}{2}(\frac{\pi}{2}-2\theta)-\frac{1}{4}(2\theta)+\frac{\sin 2\theta \cos 2\theta}{4}\right)\frac{1}{\cos^2\theta}d\theta$
which is exactly $\frac{1}{36}(9+3\sqrt 3\pi-2\pi^2)$.
Combined with the other exact results, I think it's safe to say that the probability equals $\frac{2}{\pi A}$ is proved?
Some variations that I can think of:
- Change background line segments into disks of radius 1. (Should be $\frac{1}{A}\left(\pi+\int_1^{\sqrt 2} 2r\sin^{-1}\left(\frac{1}{r}\right)dr+\int_{\sqrt 2}^2 2r\cos^{-1}\left(\frac{r}{2}\right)dr\right)=\frac{\pi+2}{A}$ if my calculation is correct.)
- Disks of radius R.
- Empty circles of radius R<0.5. (Expected number of intersections, or probability of intersecting.)
- Empty circles of radius R>0.5. (Expected number of intersections, or probability of intersecting.)
Are the expected numbers for cases 3 and 4 the same as considering the circle as the limit of an $n$-gon as $n\rightarrow\infty$? From the linearity of expectation, I expect that... If these problems turn out to be interesting, I'll post them in a seperate question.