# Calculate variance of random walk?

How can I symbolically calculate the variance of the following random walk in Mathematica?

Given several discrete random variables such that $p(Z_i=1-2k)=p$, where $k$ is a small real number, and $p(Z_i=-1)=1-p$, a random walk is the sum $X_t = \sum\limits_{i=1}^t Z_i$.

The expectation is given by: $$\mathbb{E}[X_t] = \sum\limits_{i=1}^t\mathbb{E}[Z_i] = \sum\limits_{i=1}^tp(1-2k) -(1-p) = (p(1-2k)+p-1)t$$

I would like to calculate the variance of the random walk $Var[X_t]$.

I tried using EmpiricalDistribution, but it does not accept symbolic values.

EDIT

After a bit more research into Mathematica's documentation I found the function TranformedDistribution. Since my random walk does not have unit steps I thought maybe the distribution can be obtained from a Bernoulli like this:

TransformedDistribution[
If[\[FormalX] == 1, 1 - 2 k, -1], \[FormalX] \[Distributed]
BernoulliDistribution[p]]


Could someone please show me how to use this to calculate $Var[X_t]$? As someone in the comments said, the variance of $X_t$ is the sum of variances of $Z_i$ so at some point I will have to calculate $E[Zi^2]$ where $Z_i$ is a tranformed Bernoulli distribution like I attempted above?

-
Have a look at RandomWalkProcess. – Silvia May 3 '13 at 18:47
This isn't really a question about Mathematica; it's a math-stat question. The answer is that the variance of $X_t$ is the sum of the variances of the $Z_i$ and the variance of $Z_i$ equals $p(1-p)(2-2k)^2$. – whuber May 3 '13 at 20:00
Thanks it would be instructive to see how you calculated variance of $Z_i$ because I don't know how to calculate $E[Z_i^2]$. I posted here because I also would like to see how you can use Mathematica to calculate this. – dabd May 3 '13 at 20:33
@whuber poor original poster: --> Started off at math.SE, ... ignored there perhaps because of the Mma reference ... comes here ... and is shunted back there :) – wolfies May 4 '13 at 15:58
Essentially all the work needed to solve this takes place in order to write it down in Mathematica. $Z_i$ has a Bernoulli distribution that is shifted in mean and rescaled. Its variance will therefore be the variance of a Bernoulli distribution multiplied by the square of the scale factor. One way to obtain the scale factor is by looking at the relative range: $(1-2k-(-1))/(1-0)=2-2k$. If you don't know the variance of a Bernoulli distribution you would then type Variance[BernoulliDistribution[p]](1-2 k-(-1))^2. $X_t$, being the sum of $t$ of these, will have $t$ times the variance. – whuber May 6 '13 at 14:58