Modified MovingAvg.m Bug and Rewrite to Python code