Suppose we have a 1D domain $x\in[0,\infty)$ and particles released at $x=0$ are doing simple random walks along the domain with reflecting boundary conditions at x=0. Then we can write down the evolution equation of particle position. If we derive the mean and variance of the particle distribution as functions of time, would the the instantaneous diffusion rate be $D=\frac{1}{2}\frac{d\sigma^2(t)}{dt},$ where $\sigma^2(t)$ is the variance if the mean $E(x(t))^2$ is nonzero? If so, why it is not $D=\frac{1}{2}\frac{d\sigma^2(t)+E(x(t))^2}{dt}$, half of the derivative of the second moment, which represents the mean square displacement. Thanks in advance.

$\begingroup$
$\endgroup$

Without the reflecting boundary condition, the diffusion coefficient follows from the mean square displacement, $$E[x(t)^2]=2Dt.$$ Reflections at the origin have no effect on this expectation value, so the equation still holds.