Prove that $E([c-U]) = c-1$ I have a uniform random number: $U  \in (0,1)$ and a constant scalar, $c$. I want to evaluate the expectation:
$$E([c-U])$$
where $[x]$ is the greatest integer less than or equal to $x$. Simulation shows that this equals $c-1$ (Python code below). How do I prove this?
import numpy as np
np.mean([int(i) for i in 3.2-np.random.uniform(size=10000)])

Replace the $3.2$ with any other number, $c$ and you always get something very close to $c-1$.
 A: The expected value is
$$\mathbb{E}[\textrm{floor}(c-U)]=\int_0^1\textrm{floor}(c-u)du$$
Let us assume $c \in \mathbb{N}$. Then $\textrm{floor}(c-u)$ is almost surely equal to $c-1$, then $\mathbb{E}[\textrm{floor}(c-U)]=c-1$. This is because $\textrm{floor}(c-u)$ can take a value different from $c-1$ only if $u=0$ but such event has probability zero:
$$\mathbb{E}[\textrm{floor}(c-U)]=(c-1)P(u\in(0,1])+cP(u\in\{0\})=c-1$$
Let us assume a more general $c \in \mathbb{R}$ such that $n<c<n+1$. We have that $\textrm{floor}(c-u)=n$ if $c-u\geq n$ and $\textrm{floor}(c-u)=n-1$ if $c-u<n$. Therefore
$$\mathbb{E}[\textrm{floor}(c-U)]=nP(u\in[0,c-n])+(n-1)P(u \in (c-n,1])=$$
$$=n(c-n)+(n-1)(1-c+n)=nc-n^2+n-nc+n^2-1+c-n=c-1$$
A: I'd like to prove a generalization which is very helpful in various contexts (like here: Need help validating a proof that for any point process with MTBF $t$, the events in an interval sized $u$ will be $\frac{u}{t}$). I'll prove (if $\eta$ is a random variable with mean $0$ and that's all we know about it):
$$E([c+\eta-U]) = c-1$$
using the result from @Snoop above.
First, we condition on $\eta$ to get:
$$E([c+\eta-U]|\eta) = c+\eta-1$$
Now, take expectation again
$$E([c+\eta-U]) = E(E([c+\eta-U]|\eta)) = E(c+\eta-1) = c-1$$
