I had asked this question at an initial level before; thank you to all with your suggestions. Now this problem is getting complicated and I am unable to figure it out.
There is a 10x10 matrix of zeros (call it tab
). The first row of tab needs to be replaced with the first row of tab1 (3x10 matrix)
tab1= {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, {3,
3, 3, 3, 3, 3, 3, 3, 3, 3}}
rnorms
is a matrix 10x10 of random normal variables: you can define it whatever way you want
The issue is that subsequent rows of tab
depend on the previous rows of tab given
tab[[1]]=tab1[[1]]: alpha=.011, sigma=0.127
tab[[2]]=1.011*tab[[1]]+0.127*rnorms[[1]]*tab[[1]]
tab[[3]]=1.011*tab[[2]]+0.127*rnorms[[1]]*tab[[2]]
and so on.
For each value of tab1[[1]]
, I will get a matrix of tab
; so the matrix should be repeated 3 times.
For each time, I want to store the sum of the columns of the matrix. The resulting matrix (of sums of columns) should have dimensions 3x10.
For getting the matrix tab to be repeated 3 times (based on the values of tab1), I have tried
(NestList[{(1 + alpha) #[[1]] + sigma rnorms[[#[[2]]]] #[[1]], #[[2]] + 1} &,
{#, 1}, 9] & /@ tabl)
which is giving me the wrong result (I have tried to compute each matrix manually by replacing the first row of tab). More so, I get
{{{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 1},
{{1.09703, 1.0021, 1.04791, 1.10641, 0.836817, 0.950917, 1.18247, 0.941276,
1.07136, 1.01164}, 2},.........
{{{2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, 1},
{{2.19405, 2.00421, 2.09581, 2.21281, 1.67363, 1.90183, 2.36493,
1.88255, 2.14271, 2.02327}, 2},
{{2.21106, 1.95679, 2.35947, 2.00476, 1.31318, 2.25086, 1.93982,
1.83749, 2.5103, 1.896}, 3},.........
and so on.
The above command of NestList
is not taking each row of rnorms
and multiplying it with the given row of tab1[[1]]
and then computing the whole matrix each time. I would appreciate any help.