Mean-Median Map

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

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

Try it out:

nextVal[{4,5,8}]

Write another module that returns the sequence starting with some list of values.

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

Try it out:

myseq=computeSeq[{8,4,7.8},100]

ListPlot[myseq]

Investigate the sequence of medians

medians=Table[ Median[ myseq[[;;k]] ], {k,1,Length[myseq]}]

ListPlot[medians,PlotRange->All]