Mean Median Map

Write a module that takes any list of values and returns the next value defined by the mean-median map.

nextVal[vals_]:=Module[{next,n=Length[vals]},
next = (n+1)Median[vals]-Total[vals];
next  (* return next *)
]

Try it out on some test sequences:

nextVal[{7,2}]

nextVal[{7,11,2}]

nextVal[{7,11,2,8}]

Write another module that returns a sequence of a certain length, starting with a given sequence.

computeSeq[vals_,length_]:=Module[{next,newvals=vals},
Do[
next=nextVal[newvals];
AppendTo[newvals,next],
length
];
newvals
]

Try it out:

computeSeq[{7,11,2},20]