blob: e32a77754b255ac3ad03869f4654c5dd67b8f08d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import numpy as np
import optparse
def main():
cmdlineParser = optparse.OptionParser(usage="")
(options, args) = cmdlineParser.parse_args()
path = args[0]
window = int(args[1])
half_window = window/2
f = open(path, "r")
numbers = []
for line in f.readlines():
numbers.append(float(line))
for i in range(len(numbers)):
min_id = max(0, i-window)
print(np.average(numbers[min_id:i+1]))
if __name__ == "__main__":
main()
|