I was doing some software engineering and wanted to have a thread do something in the background to basically just waste CPU time for a certain test.

While I could have done something really boring like for(i < 10000000) { j = 2 * i }, I ended up having the program start with $1$, and then for a million steps choose a random real number $r$ in the interval $[0,R]$ (uniformly distributed) and multiply the result by $r$ at each step.

  • When $R = 2$, it converged to $0$.
  • When $R = 3$, it exploded to infinity.

So of course, the question anyone with a modicum of curiosity would ask: for what $R$ do we have the transition. And then, I tried the first number between $2$ and $3$ that we would all think of, Euler's number $e$, and sure enough, this conjecture was right. Would love to see a proof of this.

Now when I should be working, I'm instead wondering about the behavior of this script.

Ironically, rather than wasting my CPUs time, I'm wasting my own time. But it's a beautiful phenomenon. I don't regret it. $\ddot\smile$

  • 13
    $\begingroup$ If the threshold really is $e$, I'm ready for my mind to be blown. $\endgroup$ – littleO Sep 13 '19 at 17:22
  • 2
    $\begingroup$ Same question popped up more recently here: math.stackexchange.com/questions/3355832/… $\endgroup$ – Gerry Myerson Sep 14 '19 at 3:55
  • $\begingroup$ @littleO. Now, what ? $\endgroup$ – Tom-Tom Sep 18 '19 at 6:27

EDIT: I saw that you solved it yourself. Congrats! I'm posting this anyway because I was most of the way through typing it when your answer hit.

Infinite products are hard, in general; infinite sums are better, because we have lots of tools at our disposal for handling them. Fortunately, we can always turn a product into a sum via a logarithm.

Let $X_i \sim \operatorname{Uniform}(0, r)$, and let $Y_n = \prod_{i=1}^{n} X_i$. Note that $\log(Y_n) = \sum_{i=1}^n \log(X_i)$. The eventual emergence of $e$ as important is already somewhat clear, even though we haven't really done anything yet.

The more useful formulation here is that $\frac{\log(Y_n)}{n} = \frac 1 n \sum \log(X_i)$, because we know from the Strong Law of Large Numbers that the right side converges almost surely to $\mathbb E[\log(X_i)]$. We have $$\mathbb E \log(X_i) = \int_0^r \log(x) \cdot \frac 1 r \, \textrm d x = \frac 1 r [x \log(x) - x] \bigg|_0^r = \log(r) - 1.$$

If $r < e$, then $\log(Y_n) / n \to c < 0$, which implies that $\log(Y_n) \to -\infty$, hence $Y_n \to 0$. Similarly, if $r > e$, then $\log(Y_n) / n \to c > 0$, whence $Y_n \to \infty$. The fun case is: what happens when $r = e$?

  • 2
    $\begingroup$ I accepted your answer, as it is an excellent explanation! Thank you for taking the time! $\endgroup$ – Jake Mirra Sep 13 '19 at 17:33
  • 2
    $\begingroup$ Was thinking a bit about your question of "what happens when r = e", and all I can say is that, once you look at it on a logarithmic scale, it's a weird, sort of lopsided random walk through the reals where you sometimes take giant steps backwards and then lots of small steps forward. $\endgroup$ – Jake Mirra Sep 13 '19 at 18:01
  • 1
    $\begingroup$ Yep! And you can convince yourself that even though those increments are unbounded (on the negative side), they still have a finite variance... $\endgroup$ – Aaron Montgomery Sep 13 '19 at 18:13
  • 1
    $\begingroup$ @AaronMontgomery - what happens when $r=e$? I am not good with the details of probability theory. Does $\{Y_n\}$ converge (to $1$) or does it not converge? And what has the finite variance (of $\log X_i$) got to do with it? Intuitively I would guess the sequence does not converge, but your mention of finite variance seems to hint that it would... $\endgroup$ – antkam Sep 13 '19 at 19:53
  • 1
    $\begingroup$ When $r = e$, the fact that we are taking an average of the $\log(X_i)$ variables (which have finite variance) means that we can use the Central Limit Theorem to proceed. This implies that $\sqrt n \overline X$ converges (in distribution only, NOT almost surely) to a normal variable with mean $0$ and variance $\sigma^2$ (i.e. the variance of $\log(X_i)$), so $\log(Y_n)/\sqrt n$ does the same. Consequently, $Y_n$ just becomes diffuse, and on individual realizations it will wander, much like an ordinary random walk will do. $\endgroup$ – Aaron Montgomery Sep 13 '19 at 20:03

I found the answer! One starts with the uniform distribution on $ [0,R] $. The natural logarithm pushes this distribution forward to a distribution on $ (-\infty, \ln(R) ] $ with density function given by $ p(y) = e^y / R, y \in (-\infty, \ln(R)] $. The expected value of this distribution is $$ \int_{-\infty}^{\ln(R)}\frac{y e^y}{R} \,\mathrm dy = \ln(R) - 1 .$$ Solving for zero gives the answer to the riddle! Love it!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.