I try to program a sum of two moving averages in R. I think I have it right, but I get unexpected results. So I am afraid that my function is not good. Can anyone help me?

This is what I try to program $\displaystyle X_n = \sum_{j=1}^{10} \frac{1}{j+1)^2} A_{n-j} + \sum_{j=1}^{10} \frac{1}{(j+1)^3} B_{n-j} $. A and B are two random variables.

This is my code:

ma = function(){

a = rpareto(10000, 1, 1.5)

b = rpareto(10000, 1, 1.5)

x = c(1,a[1:9999])/4 //This is the first term $\displaystyle A_{n-1}$

for (i in 2:10)

x = x + c(1:i,a[110000-i)])/(i+1)^2 \\ I make nine new terms and add them

\\ The same procedure for the second summation

y = c(1,b[1:9999])/8

for (i in 2:10)

y = y + c(1:i,b[110000-i)])/(i+1)^3

\That is what I display

x[11:10000]+y[11:10000]

}