Given 2 randomly independently distributed variables, I would like to calculate the expected distance to the origin. This problem seems to be equivalent to calculating the average distance of all points to a corner of a square.
-
2How are the two random variables distributed? – Henry Jun 13 '21 at 23:42
-
If this is a uniform distribution on a unit square, the answer seems to be $\frac13\left(\sqrt{2}+\log_e(\sqrt{2}+1)\right)$ – Henry Aug 11 '22 at 15:36
2 Answers
Once you specify the distributions of the two variables, $f_{x}(x)$ and $f_{y}(y)$, the value you're looking for is
$$ \int_{-\infty}^{\infty}\int_{-\infty}^{\infty} f_{x}(x)f_{y}(y) \sqrt{x^2 + y^2} dx dy $$
For example, if $X$ and $Y$ are both uniform(0,1), this is
$$ \int_{0}^{1}\int_{0}^{1} \sqrt{x^2 + y^2} dx dy \approx 0.765 $$
If you want to use a different measure of distance you can replace $\sqrt{x^2 + y^2}$ by your preferred norm, $ \lVert (x ,y)\rVert$
- 90,934
- 2,670
If the two random variables are IID $\mathsf{Unif}(0,1),$ then you can find the exact answer using the formula in @DavidLukeThiessen's Answer (+1). Or you can approximate the answer by simulation as follows:
set.seed(2021)
x = runif(10^6); y = runif(10^6)
d = sqrt(x^2 + y^2)
mean(d)
[1] 0.7653568
The shape of the distribution of the distance is suggested by the histogram below.
hist(d, prob=T, br=60, col="skyblue2")
- 56,185
