Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Revised moving average question' topicStudent Support Forum > General > Archives > "Revised moving average question"

Help | Reply To Topic
Author Comment/Response
05/14/12 4:26pm

List={{"a", 1, 4}, {"a", 2, 1}, {"a", 3,6}, {"a", 4, 10}, {"a", 5, 18},{"a",5,91},{"a",1,21},{"a",3,98},{"a",3,9}} 

element={"a", 1, 4} 




I want to take the (moving average of position3) and divide position3 by the moving average of position3 y units forward.

for example, lets say... 
length of moving average= x
offset division= y 

and lets just look at position 3 just for clarity.



moving average= {5/2, 7/2, 8, 14, 109/2, 56, 119/2, 107/2}
notice that the lists are not the same length? I want to chop off the front of {4,1,6,10,18,91,21,98,9} so that they are the same length.
FYI (as the length of the moving average increases, the difference in lengths of the moving average relative to original list increases)

so now we have chopped position3 {1,6,10,18,91,21,98,9} and moving average of position3 {5/2, 7/2, 8, 14, 109/2, 56, 119/2, 107/2} which are equal in length. (length of 8)

now that they are equal in length, lets move the moving average list y units forward; y=3 in this case. {18/(5/2),91/(7/2),21/8,98/14,9/(109/2)}
FYI (notice that this operation makes the length decrease from 8 to 5)

which simplifies to {36/5, 26, 21/8, 7, 18/109}

this would be the final output

{"a", 5, 18,36/5},{"a",5,91,26},{"a",1,21,21/8},{"a",3,98,7},{"a",3,9,18/109}

FYI(we looked at position3 for clarity, remember that we are doing the operation on the list and a position4 is created using position3)

URL: ,
Help | Reply To Topic