# What is the probability density function over time for a 1-D random walk on a line with boundaries?

If a single particle sits on an infinite line and undergoes a 1-D random walk, the probability density of its spatio-temporal evolution is captured by a 1-D gaussian distribution.

\begin{align} P(x,t)&=\frac{1}{\sqrt{4 \pi D t}}e^{-\frac{(x-x_0)^2}{4Dt}} \end{align}

However, suppose there are impassable boundaries on the line; on one side, or on both sides. Are there any boundary conditions for which there exists a closed form probability density function for how this particle will behave over time? Any references to such solutions would be extraordinarily helpful.

EDIT. Attempting to generalize Emilio's result below for an arbitrary initial particle position $-L/2 < x_0 < L/2$.

I had to work it out by example. I found the following "images" were required to account for reflections of an off-center particle at position $x_0$: for the first and second reflections on both sides the new gaussians had to be centered on ($-2L+x_0$, $-L-x_0$, $x_0$, $L-x_0$, $2L+x_0$). From the pattern I think the full solution can be expressed, for all integers $n$, as:

\begin{align} P(x,t)&=\frac{1}{\sqrt{4 \pi D t}}\sum_{n=-\infty}^\infty e^{-\frac{(x-nL-(-1)^nx_0)^2}{4Dt}} \end{align}

where the old $x_0$ is now defined as $nL+(-1)^{n}x_0$

-
what type of steps are you taking? Also, what do you mean be "impassible"? Do you mean you reject any step that takes you over the boundary? – Mike Flynn Jul 19 '13 at 17:47
Periodic boundary conditions spring to mind. – Johannes Jul 19 '13 at 17:58
General word of advice: "closed form" isn't terribly well defined. What people generally mean is "in terms of nice functions that I like and understand" but this is clearly subjective. There are many solutions to physically-inspired math problems are perfectly well-behaved and analytic, but that no one has bothered assigning abbreviations to like $\mathrm{e}$, $\sin$ or $J_0$. These functions are still manipulable and easily calculable to arbitrary precision. – Chris White Jul 19 '13 at 18:00
Why is there a closevote on this? It is a perfectly legitimate, well defined and well formulated question. – Dilaton Jul 19 '13 at 19:19
@MikeFlynn exactly. There are multiple ways to impose a boundary condition where particles are not permitted to pass beyond, and I'm interested for now in any of those conditions. – vector07 Jul 21 '13 at 5:34

This can probably be solved by the method of images, depending on your precise formulation of the problem. The main idea would be to place image particles at the initial time at positions given by treating your impassable boundaries as mirrors; this makes the probability flow at the boundary zero.

To give a more precise formulation, suppose your problem is $$\frac{\partial P}{\partial t}=D\frac{\partial^2P}{\partial x^2}\text{ under }\frac{\partial P}{\partial x}(-L/2,t)=0=\frac{\partial P}{\partial x}(L/2,t)\text{ and }P(x,0)=\delta(x),$$ where I've initially placed the particle in the middle of the barriers for simplicity but this can be altered. The solution is then given, by linearity, by your expression, added up for $x_0=nL$ for all integers $n$: $$P(x,t)=\frac{1}{\sqrt{4 \pi D t}}\sum_{n=-\infty}^\infty e^{-\frac{(x-nL)^2}{4Dt}}.$$ This can be solved exactly in terms of Jacobi theta functions, which makes the calculations and graphing a lot faster, but does not necessarily (at a first go) make this easier to work with: $$P(x,t)=\frac{1}{L}\vartheta _3\left(\frac{\pi x}{L},e^{-\frac{4 D \pi ^2 t}{L^2}}\right).$$ (For asymetrically placed initial particles, you would have two series of gaussians separated by $2L$, so therefore two theta functions.)

I'm not sure this is very useful by itself, but the method of images is very powerful.

-
There was also good fun in taking $P\mapsto\psi$ to be a wavefunction. This forces you to re-normalize, and the dependence of this factor on $D$, if I remember correctly, are a nice exercise for someone with much too much time on their hands. – Emilio Pisanty Jul 19 '13 at 18:25
Just a comment on series solutions: I think your example converges pretty quickly, but with different boundary conditions the convergence can be very slow. It is worth trying the Poisson summation theorem in these cases. In the linked case Poisson summation unexpectedly collapsed a numerically awful series (thousands of terms needed) to a very simple analytic solution. – Michael Brown Jul 20 '13 at 9:58
Interesting, I need to digest this. What exactly does a mirror boundary imply? Is it equivalent to saying that for a specific particle trajectory, a particle that might have traveled distance $x_a+x_b$, where $x_a$ is the distance to the boundary, and $x_b$ is the distance it might have traveled past the boundary, instead travels distance $x_a-x_b$? – vector07 Jul 21 '13 at 5:45
@vector07 Yeah, that's about it. You "fold back" all trajectories at the boundary, which means the boundary has probability 1 of reflecting. For every trajectory that travels $x_a-x_b$ there are then equally many that go left as well as right, so that mid-interval points still have probability 1/2 for right and left. – Emilio Pisanty Jul 21 '13 at 13:21
It is easier, though, to re-think the "folding back" as adding another mirrored copy of your trajectory tree behind the "mirror" at the boundary. – Emilio Pisanty Jul 21 '13 at 13:22

Your solution is in fact a particular solution of the 1-Dimensional heat equation, $\frac{\partial P}{\partial t} = D \frac{\partial^2 P}{\partial x^2}$,with initial condition $P(x,0) = \delta (x-x_0)$

A traditionnal way to solve this equation is to use Fourier Series

See some solutions in 1-D, like homogeneous equations or inhomogeneous equations, or other examples

-