From: rtrimana Date: Wed, 8 Nov 2017 00:45:24 +0000 (-0800) Subject: Adding moving window average using numpy library X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=38e85fbaaea37e40593772f1867aaae3eafb9bae;p=pingpong.git Adding moving window average using numpy library --- diff --git a/parser/parse_packet_frequency.py b/parser/parse_packet_frequency.py index ee4cee5..5bc1a35 100644 --- a/parser/parse_packet_frequency.py +++ b/parser/parse_packet_frequency.py @@ -23,8 +23,8 @@ TABLE_HEADER_X = "Timestamp (hh:mm:ss)" TABLE_HEADER_Y = "Packet frequency (pps)" # Use this constant as a flag -WINDOW_SIZE = 3 -USE_MOVING_AVERAGE = False +WINDOW_SIZE = 5 +USE_MOVING_AVERAGE = True def moving_average(array, window=3): @@ -32,6 +32,8 @@ def moving_average(array, window=3): Args: array: array of numbers window: window of moving average (default = 3) + Adapted from: + https://stackoverflow.com/questions/14313510/how-to-calculate-moving-average-using-numpy """ # Check if window > len(array) if window > len(array):