10
$\begingroup$

Choose a point uniformly in a unit square. What is the expected value of its distance from the furthest edge of the square?

I got $\dfrac{3}{4}$ by considering the probability of $\max(x,1-x,y,1-y)$, but this seems to be wrong. Can someone point me in the right direction?

$\endgroup$
1
  • $\begingroup$ In fact the distance from the furthest edge of the square is indeed $\max(x,1-x,y,1-y).$ What's unclear is how you could get $3/4$ for the expected value of that random variable. So we can't tell whether you went wrong via an arithmetic error, a fundamental misunderstanding, or something else. $\endgroup$ Commented yesterday

5 Answers 5

12
$\begingroup$

The PDF of $(x,y)$ is $p(x,y)=1$($0\leqslant x\leqslant1$, $0\leqslant y\leqslant1$). What we need is $$ \int_0^1\int_0^1\max\{x,1-x,y,1-y\}\mathrm{d}x\mathrm{d}y $$ By symmetry, the integral values are the same in the four regions separated by the diagonals, so the result is $$ \begin{aligned} &\phantom{{}={}}4\int_0^{\frac{1}{2}}\int_x^{1-x}(1-x)\mathrm{d}x\mathrm{d}y\\ &=4\int_0^{\frac{1}{2}}(1-x)(1-2x)\mathrm{d}x\\ &=\frac{5}{6}. \end{aligned} $$

$\endgroup$
0
7
$\begingroup$

This is not a complete answer, but rather an additional remark. Although in this example it is straightforward to compute the exact expected value, this is not always feasible in more complex scenarios. In such cases, Monte Carlo simulation provides an effective method to approximate the expected value and to detect potential errors in analytical derivations. In the figure below, one simulation run with 10.000 sample points is shown.

The Monte Carlo simulation consisted in generating $n=10000$ pairs $(x_i, y_i), \,\,i=1, \cdots, n$ of uniformly distributed numbers in $[0,1]$ and obtaining the estimate $$ \mathbb{E}(\max\{X, Y, 1-X, 1-Y\})\approx \dfrac{1}{n}\sum_{i=1}^n \max\{x_i, y_i, 1-x_i, 1-y_i\} $$ Based on a particular run, the estimate for the expected value is $0.83385$, which is very close to the exact value $\frac{5}{6} \approx 0.83333$.

enter image description here

As a curiosity, the simulation was ran in Wolfram Mathematica, with the following code:

tab = Table[{Random[], Random[]}, {i, 1, 10000}];

dist = Table[Max[tab[[i, 1]], tab[[i, 2]], 1 - tab[[i, 1]], 1 - tab[[i, 2]]], {i, 1, Length[tab]}];

Total[dist]/Length[tab]

$\endgroup$
1
  • $\begingroup$ This simulation approach is highly effective for random or irregular shapes - areas and volumes, so good to have an example in play. $\endgroup$ Commented 2 days ago
4
$\begingroup$

In general, divide the unit hypercube $I=[0,1]^n$ into $2^n$ smaller hypercube cells of side lengths $\frac12$. By symmetry, the expected distance from a random point in each cell to the farthest side of $I$ remains the same, regardless of the cell chosen. Hence it suffices to consider a random point $x\in[0,\frac12]^n$. Then \begin{align*} E[\max(x_1,1-x_1,\ldots,x_n,1-x_n)] &=E[\max(1-x_1,\ldots,1-x_n)]\\ &=1-E[\min(x_1,\ldots,x_n)]\\ &=1-\frac12E[\min(y_1,\ldots,y_n)] \end{align*} where $y=2x$ is a random point uniformly chosen from $[0,1]^n$. It is well known that $E[\min(y_1,\ldots,y_n)]=\frac{1}{n+1}$. Hence the answer to our question in $n$ dimensions is $\frac{2n+1}{2n+2}$, which becomes $\frac56$ when $n=2$.

$\endgroup$
2
$\begingroup$

Here's how to do it by conditional probability. Picking a point uniformly at random inside the square has the distribution as $(X,Y)$ where $X,Y$ are iid Uniform$[0,1]$ random variables.

Let $D$ be the quantity you want, the maximum distance from the furthest edge.

$E(D)=E(E(D|X=x))$.

Now, if $X=x$, and suppose $x\leq 0.5$, then $D=\begin{cases}1-Y\quad, Y\leq x\\1-x\quad ,x\leq Y\leq 1-x\\ Y\quad ,1-x\leq Y\leq 1\end{cases}$

Similarly do the same for $0.5\leq x\leq 1$.

So $$E(D|X=x)=\begin{cases}1-(1-x)^{2}+(1-x)(1-2x)\qquad ,0<x\leq 0.5\\ 1-x^{2}+x(2x-1)\qquad,1>x>0.5\end{cases}$$

So $$E(D)=\int_{0}^{1/2}1-(1-x)^{2}+(1-x)(1-2x)\,dx+\int_{1/2}^{1}1-x^{2}+x(2x-1)\,dx\\ =\frac{5}{12}+\frac{5}{12}=\frac{5}{6}\qquad\Box$$


Alternatively, $E(D)=E(D|X=x,X\leq \frac{1}{2})P(X\leq \frac{1}{2})+E(D|X=x,X\geq \frac{1}{2})P(X\geq \frac{1}{2})$

In both cases, the expectations must equal by symmetry. Also, conditioned on $X\leq \frac{1}{2}$, $X$ has Uniform$[0,\frac{1}{2}]$ distribution.

\begin{align}E(D)&=2\cdot\int_{0}^{1/2}\bigg(\int_{0}^{x}(1-y)\,dy+\int_{x}^{1-x}(1-x)\,dy+\int_{1-x}^{1}y\,dy\bigg)\,dx\\ &=\frac{5}{6}\qquad \Box\end{align}

$\endgroup$
2
$\begingroup$

$\frac34$ is the answer to a different question, the expected larger distance to the ends of the unit interval $[0,1]$. One way of answering that is to say that the largest distance is clearly between $\frac12$ and $1$, the probability the distance is less than or equal to $z$ is $2z-1$ (the CDF) so the density is $2$ on this interval, and $\int\limits_{1/2}^1 z\,2\, dz =\frac34$.

In your question, the distance to the furthest edge is similarly between $\frac12$ and $1$, the probability the distance is less than or equal to $z$ is $(2z-1)^2$ (the CDF, but also the volume of an inner cube) so the density is $4z-2$ on this interval, and $\int\limits_{1/2}^1 z(4z-2)\, dz =\frac56.$

More generally in an $n$-dimensional unit hypercube, the distance to the furthest $(n-1)$-dimensional facet is again between $\frac12$ and $1$, the probability the distance is less than or equal to $z$ is $(2z-1)^n$ so the density is $2n(2z-1)^{n-1}$ on this interval, and $\int\limits_{1/2}^1 z\,2n(2z-1)^{n-1}\, dz =\frac{2n+1}{2n+2}.$

Note that the expected distance to the outside is $1 - $ the previous results, so would be $\frac14$ and $\frac16$ and more generally $\frac1{2n+2}$ which approaches $0$ as $n$ increases. This is sometimes called the curse of dimensionality.

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.