Escape probability for a randomly oriented, single fixed size step from a random coordinate inside a square

geometryprobability

I have a square with side length $ s $.

A (uniformly) random coordinate $ c = (x,y) $ inside this square is the origin of a (uniformly) randomly oriented vector of fixed length $ l $.

enter image description here

Vector endpoints can end up both within the square and outside of it, depending on their orientation and $ c $. The escape probability for a point is not the same everywhere, it depends on their position.

A vector starting closer to the center/halfway along the side of the square has a lower probability than one in the corner to land outside.

Point p here can reach the sides but not the corner, everything closer to the corner can do both and therefore has an even higher probability.

enter image description here

So how does this probability distribution $ P_{escape}(s,l,x,y) $ look like?

Can it be used to express the average expected escape probability for large amounts of randomly chosen vectors analytically?

$ P_{escape}(s,l) = ? $

Some possibly irrelevant notes:

In the special case where $ l<s/2 $, there exists in the center of the square a region (here in green) where vectors, regardless of orientation, cannot reach the edge. In this special case, there is also a segment of the square edges that have probability 1/2

Also, if $ l = 0 $, then $ P(s,l) = 0 $, or if $ l > \sqrt{2*s^2} $, then $ P(s,l) = 1 $

Best Answer

To simplify things a little, let's make $s=2$ and we'll consider the square $S$ with vertices $(\pm1,\pm1)$.

Say the start point of the vector is $P(u,v)$ and its angle (measured anticlockwise from the positive $x$-axis, as usual) is $\theta$.

Then the endpoint of the vector is $Q(u+l \cos \theta,v+l \sin \theta)$.

It's tempting to pick $P(u,v)$ and work out the range of $\theta$ that makes $Q$ outside $S$, but this makes calculations very messy.

It's better to fix $\theta$, and consider the ranges of $u$ and $v$.

Let's restrict $\theta$ to be in the range $\left(0,\frac{\pi}{2}\right)$ (this will actually cover all cases, by symmetry). This means both $\cos \theta$ and $\sin \theta$ are positive.

We need to consider the cases $l \le 2$ and $l>2$ separately.


Case $l \le 2$

For the point $Q$ to be inside $S$, we need both $$-1<u<1-l \cos \theta$$

and

$$-1<v<1-l \sin \theta$$

These inequalities define a rectangle, with area $$(2-l \cos \theta)(2-l \sin \theta)$$

So, for a given $\theta$, the probability the point $Q$ is inside $S$ is $$P(\theta) = \frac{(2-l \cos \theta)(2-l \sin \theta)}{4}$$

(the ratio of the areas of the rectangle and the whole square).

Now, to find the overall probability, we need to integrate: $$\begin{align} P(\text{inside})&=\frac{2}{\pi} \int_0^\frac{\pi}{2} \frac{(2-l \cos \theta)(2-l \sin \theta)}{4} d\theta \\ &= 1+\frac{l(l-8)}{4\pi}\end{align}$$

So the probability we want (one minus this) is $$\boxed{P(\text{escape}) = \frac{l(8-l)}{4\pi}}$$


Case $l>2$

This method needs a slight adjustment for $l>2$. Note that now, if $P=(-1,-1)$ and $\cos \theta > \frac{2}{l}$, $Q$ will always be outside $S$.

This observation tells us what to do, though; we just change the limits for $\theta$ in the integral:

$$\begin{align} P(\text{inside})&=\frac{2}{\pi} \int_{\cos^{-1} \frac{2}{l}}^{\frac{\pi}{2} - \cos^{-1} \frac{2}{l}} \frac{(2-l \cos \theta)(2-l \sin \theta)}{4} d\theta \\ &= \frac{1}{4\pi} \left(8\sqrt{l^2-4}-16\cos^{-1} \frac{2}{l} + 4\pi - 8 - l^2 \right) \end{align}$$

So finally, in this case, $$\boxed{P(\text{escape}) = \frac{1}{4\pi} \left(8 + l^2 - 8\sqrt{l^2-4}+16\cos^{-1} \frac{2}{l} \right)}$$