$a_factor = 0.1 # You have to play with different # values of the smoothing factor to # match the data you have $new_avg = $this_period_avg*$a_factor + $prev_avg * (1 - $a_factor);