I have a random function $f(x)$ which returns one of the integers in the range $[0, x-1]$ with equal probability and $f(0) = 0$.
What is the expected value $E(f(f(f(\ldots f(x)))$ ($n$-times $f(x)$)? The answer should be a function of $x$ and $n$.
I have a random function $f(x)$ which returns one of the integers in the range $[0, x-1]$ with equal probability and $f(0) = 0$.
What is the expected value $E(f(f(f(\ldots f(x)))$ ($n$-times $f(x)$)? The answer should be a function of $x$ and $n$.
I fail to find a general pattern, but here are some results.
Write $E_n(x) = E(f^n(x))$.
It is easily seen that $E_n(x) = 0$ if $x \leq n$ and $E_n(n+1) = \frac{1}{(n+1)!}$.
Furthermore, if $x \geq 1$, we have
$$ E_1(x) = \frac{x-1}{x} + \dots + \frac{1}{x} = \frac{x-1}{2} $$
$$ E_2(x) = \frac{1}{x}\sum_{y=1}^{x-1}\frac{y-1}{2} = \frac{1}{4}\frac{(x-1)(x-2)}{x} = \frac{1}{4}\left(x-3+\frac{2}{x}\right) $$
$$ E_3(x) = \frac{1}{4x} \sum_{y=1}^{x-1}(y-3) + \frac{1}{2x}\sum_{y=1}^{x-1}\frac{1}{y} = \frac{(x-1)(x-4)}{8x} + \frac{H_{x-1}}{2x} $$
The appearance of the harmonic sum $H_x$ makes me think that no simplification will be possible in general.
Presumably you mean the interval $[0,x-1]$.
Let $Z_{1}$, $Z_{2}, \ldots Z_{n}$ be random variables with probability mass functions $f(z)$, $f^{2}(z),\ldots f^{n}(z)$ respectively. Then $P(Z_{n}=z)=P(Z_{n-1}=z|0\le z< x-n)$.
Therefore, $$f^{n}(z)=\frac{f^{n-1}(z)}{f^{n-1}(x-n)}$$
When $0\le z<x-n$, and $0$ otherwise.
According to an answer by the OP in the comments, the question is to consider a Markov chain $(X_n)_{n\geqslant0}$ such that $X_0=x$, for some $x\geqslant1$, and, for each $n\geqslant1$, conditionally on $X_{n-1}=y$, $X_n$ is uniformly distributed on $\{0,1,\ldots,y-1\}$ if $y\geqslant1$ and $X_n=0$ if $y=0$. The question is to compute $\mathbb E(X_n)$ for every $n\geqslant0$.
A standard approach is to note that $\mathbb E(X_n\mid X_{n-1}=0)=0$ and, for every $y\geqslant1$, $$ \mathbb E(X_n\mid X_{n-1}=y)=\frac1y\sum_{k=0}^{y-1}k=\tfrac12(y-1). $$ To sum up, $$ 2\mathbb E(X_n)=\mathbb E(X_{n-1}-1;X_{n-1}\geqslant1)=\mathbb E(X_{n-1})-1+\mathbb P(X_{n-1}=0). $$ On the other hand, $\mathbb P(X_n=0\mid X_{n-1}=0)=1$ and, for every $y\geqslant1$, $$ \mathbb P(X_n=0\mid X_{n-1}=y)=\frac1y, $$ hence $$ \mathbb P(X_n=0)=\mathbb P(X_{n-1}=0)+\mathbb E(1/X_{n-1};X_{n-1}\geqslant1). $$ At this point it seems necessary to compute recursively $\mathbb E(1/X_{n};X_{n}\geqslant1)$ but I am suddenly not so sure that this would make the end of the road any nearer...
So E(f(5)) = 1/5*(0 + 1 + 2 + 3 + 4) = 10 / 5 = 2
– user65009 Mar 04 '13 at 21:55