Simple finite random walks with reflective boundaries Let us take the 1D case: for an n-step random walk on a line confined between two boundaries at positions t and s, can we determine the average time (number of steps) the walker spends off the boundaries given the distance between the boundaries is d? That is, the time spent on all sites but t+1 (neighbouring site of the left boundary) and s-1 (neighbouring site of the right side boundary). 
We can reformulate the problem in terms of the complementary scenario, meaning: what is the frequency with which the walker gets reflected from the boundaries (as a function of n and d)?
It would be very interesting if someone could shed light on such properties of the finite random walker. Please let me know of anything stands vague in the above description.
 A: For a random walk on $\bf Z$ where you can jump only to your two closest neighbors, this can be computed explicitely using martingale, Markov chains or renewal theory. For more complex random walks, there are algorithms but the formulas become more complicated. 
So for example, for a random walk with absorbing barriers at 0 and n and probability p to go to the left and q to the right, we set $r = p/q$ and $t_i$ the mean time before absorption starting from $i$, then
$$ 
t_i = {1\over p-q}(n {r^n-r^{n-i} \over r^n -1} -i) \qquad  if \ p\neq 1/2
$$
$$ 
t_i = i(n-i) \qquad \ p = 1/2
$$
In the reflecting case, assuming $p=1/2$ and we stay on the reflecting barrier with probability $1/2$, the frequency $a_i$ of time spent on the state number $i$ is given by $1/{n+1}$. The limit probability is uniform. If $p$ is different than $1/2$, then
$$
a_i = {r-1\over r^{n+1} -1} r^i
$$
See kemeny, Snell, "finite Markov chains" chapter 7 for the computations and a gentle introduction to the Markov chains approach.
