I try to create code to load times series into the rows of a matrix [serie1, 2, 3, etc.] and then manipulate those time series into a loop (see code below). My problem is threefold (3 loops below):
1-how to create a loop to fill the array's rows one by one. 2-fill a 3d array of with stuff I calculate off those time series (correlation coefficients) 3-calculate the average correlation of the lower triangular matrix for each time period
what i am doing wrong?
thanks a lot for your help!
- Code: Select all
for f in fx_tech:
#i want to populate a matrix with all series, fx_tech is a list of series i have
#to feed through the "loadseries" command. I know the first set of loops is wrong.
#then loop over each series pair and populate the matrix "corr"
corr = zeros((len(time_series)-1,len(fx_tech),len(fx_tech))) #allocate matrix
while i < len(fx_tech):
while j < len(fx_tech):
corr[:,i,j] = gencorrelation(time_series[:,i],time_series[:,j],lambda1)
#finally calculate the average of the elements below the diagonal for each time period.
mean_fx = 
while i < len(time_series)-1:
diag[:,:] = corr[i,:,:]-eye(len(fx_tech))
mean_fx.append = sum(diag)/((len(fx_tech)**2)/2-len(fx_tech))