I am working with recurrence relations with a simple base:

\begin{equation} Y_i = aY_{i-1} + (1-a)X_i \quad \mbox{and if $Y_0=0$ then} \quad Y_n = (1-a)\sum_{i=1}^n a^{i-1} X_i \tag{1} \end{equation}

here, $X_i$ are identically-distributed independent random variables (although I do not want to specify a distribution type). I am then interested to characterise the series $Y_n$ (its moments, correlation structure, etc.) in terms of those of $X$ and the parameter $a$.

I have done this by hand for (1) and have obtained relationships between $\mathbf{E}[X_n]$ and $\mathbf{E}[Y_n]$, $\mathbf{Var}[X_n]$ and $\mathbf{Var}[Y_n]$, $\mathbf{skew}[X_n]$ and $\mathbf{skew}[Y_n]$, $\mathbf{Kurt}[X_n]$ and $\mathbf{Kurt}[Y_n]$ and so on, up to order 6 moments. The algebra becomes rather tedious, but just about manageable.

However, I am now interested to feed this recurrence through a subsequent equation:

\begin{equation} Z_{j} = bZ_{j-1} + (1-b)Y_j \quad \mbox{and if $Z_0=0$ then} \quad Z_n = (1-b)\sum_{j=1}^n b^{j-1} Y_j \tag{2} \end{equation}

and then find its moments. Having done that, I want to do it again.

My question is this: how (can ?) I use Mathematica to help me do this?


1 Answer 1


RSolveis the function you're looking for.

The second example evaluates to

Z = RSolveValue[{z[i + 1] == b z[i] + (1 - b) y[i], z[1] == 0}, z , i]
(*Function[{i}, b^(-1 + i) (\!\(\*UnderoverscriptBox[\(\[Sum]\), \(K[1] = 0\), \(\(-1\) +i\)]\(-\((\((\(-1\) + b)\)\ \*SuperscriptBox[\(b\), \(-K[1]\)]\ y[K[1]])\)\)\) -y[0] + b y[0])]*)


The two difference equations are solved with

{Y, Z} = RSolveValue[{
y[i] == a y[i - 1] + (1 - a) x[i], y[0] == 0, 
z[i + 1] == b z[i] + (1 - b) y[i], z[1] == 0}
, {y, z }, i] //Simplify
  • $\begingroup$ Great - but how would I ask Mathematica to find Z as a function of both y and x? $\endgroup$ Commented Mar 3, 2021 at 10:44
  • 1
    $\begingroup$ @hydrologist Both equations might be solved in one step, see my modified answer. $\endgroup$ Commented Mar 3, 2021 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.