Ruby なら、

( 1..5 ).each_cons( 3 ){ |ary| p ary }

結果
[1, 2, 3]
[2, 3, 4]
[3, 4, 5]

>もし配列の端の数字の場合は、2つの数値の平均を
こういうのは、出来ない