5

A well-known question is: On average, how many uniformly random real numbers are needed for their sum to exceed $1$? The answer is $e$.

Let's tweak the question:

On average, how many uniformly random real numbers are needed for the sum of their squares to exceed $1$?

My attempt

Let $f(n)=$ probability that the sum of squares of $n$ uniformly random real numbers is less than $1$.

The probability that the sum of squares exceeds $1$ for the first time with the $n$th random number, is $f(n-1)-f(n)$.

Then the expectation is $\sum\limits_{n=2}^\infty n(f(n-1)-f(n))$.

I have worked out that:
$f(1)=1$
$f(2)=\int_0^1\sqrt{1-{x_1}^2}dx_1$
$f(3)=\int_0^1\int_0^{\sqrt{1-{x_1}^2}}\sqrt{1-{x_1}^2-{x_2}^2}d{x_2}d{x_1}$
$f(4)=\int_0^1\int_0^{\sqrt{1-{x_1}^2}}\int_0^{\sqrt{1-{x_1}^2-{x_2}^2}}\sqrt{1-{x_1}^2-{x_2}^2-{x_3}^2}d{x_3}d{x_2}d{x_1}$
And so on.

With help from Wolfram, the above expressions are:
$f(2)=\frac{\pi}{4}$
$f(3)=\frac{\pi}{6}$
$f(4)=\frac{\pi^2}{32}$

A087299 suggests that $f(n)$ equals the ratio of the volume of an $n$-dimensional ball to the circumscribed $n$-cube, but I don't understand why. Assuming this is true, the expectation is approximately $3.9257708130843$. I don't know if this expectation has a closed form.

Dan
  • 35,053
  • 1
    Take $f(2)$ for example. If we call the integrand $x_2$ you have that $x_1^2 + x_2^2=1$, which parametrizes a circle centered at the origin. You are integrating the height of the positive part along the horizontal axis, which gives you the area of a quarter circle of unit radius. This is true for the rest of your $f(n)$ as well, they are a quarter, octant... and so on, of a unit radius hypersphere. Since there are $2^n$ equal chunks, the total volume of the hypersphere is $2^n f(n)$. The volume of the corresponding hypercube is $2^n$, and the quotient is just $f(n)$. – Diego Dec 13 '23 at 17:05

1 Answers1

9

Simulation in R suggests something near $3.926$ is reasonable.

set.seed(2023)
squaresto1 <- function(power=2, target=1, maxcases=100){
  cs <- cumsum(runif(maxcases)^power) 
  min(which(cs > target))
  }
sims <- replicate(10^6, squaresto1(power=2, target=1))
mean(sims)
# 3.926359

Ways of thinking about this include:

  • You can extend the uniform distribution on $[0,1]$ to $[-1,1]$ without affecting the distribution of absolute values or squares

  • This becomes a uniform distribution in the hypercube $[-1,1]^n$ when you take $n$ points

  • The (square root of) the sum of squares is less than $1$ for points in the $n$-ball radius $1$

  • The probability the first $n$ squares add up to less than $1$ is the proportion of a hypercube contained in the the largest $n$-ball that fits inside it.

  • The volume of the $n$-ball is $\frac{\pi^{n/2}}{\Gamma\left(\frac n2+1\right)}$ while the volume of the hypercube is $2^n$

  • You can find the expected number needed to reach $1$ by summing over $n$ the probabilities that more are needed.

So your expression is $\sum\limits_{n=0}^\infty \dfrac{\pi^{n/2}}{2^n \,\Gamma\left(\frac n2+1\right)}$. This does have a simplified form if you use the CDF of a normal distribution or the error function, namely $$2\, e^{\pi/4}\, \Phi\left(\sqrt{\frac \pi 2}\right) \approx 3.92577.$$ As a check:

n <- 0:100
sum(pi^(n/2) / (2^n * gamma(1+n/2)))
# 3.925771

2 * exp(pi/4) * pnorm(sqrt(pi/2))

3.925771

Henry
  • 169,616