# Calculating the accumulate moving average of a group of data in Table

basically I have a group of data in dimension (21*51), I managed to generate the name of the file and Imported into a Table

 name = Table[StringTemplate["/Users/Projekt/output/log/b7_tt_aa.dat", InsertionFunction -> (ToString@NumberForm[#, {2, 2}] &)]@<|"t" -> 0.01 k, "a" -> 0.01 l|>, {k, 1, 21}, {l, 0, 50}];
data = Table[Import[name[[i, j]]], {i, 1, 21}, {j, 1, 51}]


The dimension of both name and data are

 In= Dimensions[data]
Out= {21, 51}


Now, each file has a list of numbers, and I intend to do the calculation of accumulative moving average of each file, and put them under one table for later use, I know for each single file the method would simply be for example

cma = Accumulate[data1]/Range[1, Length[data1]]


but when I change data into data[[i,j]] and define {i,1,21},{j,1,51}, it will simply break down, much appreciate if anyone can give me some help!

• There's MovingAverage. Dec 16 '16 at 10:59
• I just calculate the average with respect to the current number of data, not by a fixed window Dec 16 '16 at 11:06
• cma = Table[ Accumulate[data[[i]]]/Range[1, Length[data[[i]]]], {i, 1, Length@data}] Dec 16 '16 at 11:22
• Hi@corey979, I'm not sure if the code works or not, because it consumes too much memory, my 16Gb ram is simply not enough, is there a computationally cheaper way to do this? Dec 16 '16 at 22:41
• This code, for data = RandomReal[1, {21, 51}] having Dimensions@data == {21, 51}, runs in 0.002418 sec (AbsoluteTiming). I cannot know what are you doing there; maybe you have some old definitions, corrupted data, or your data has some other format than follows from your question. Dec 16 '16 at 22:51

By the method mentioned in the question, the actual Dimension for data would be {21,51,Length[data],1}.
Table[Accumulate[data[[i, j]]]/Range[1, Length[data[[i, j]]]], {i, 1, 21}, {j, 1, 50}]