0

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.

2 Answers2

3

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$

Sycorax
  • 90,934
2

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")

enter image description here

BruceET
  • 56,185