forked from SGenheden/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmad.py
More file actions
24 lines (19 loc) · 699 Bytes
/
mad.py
File metadata and controls
24 lines (19 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Author: Samuel Genheden samuel.genheden@gmail.com
"""
Program that prints the MAD of the first and second column from standard input.
The data on standard input should contain nothing but numbers in rows and columns.
"""
import sys
import numpy as np
from sgenlib import parsing
if __name__ == '__main__':
domax = len(sys.argv) == 2 and sys.argv[1] == "x"
domed = len(sys.argv) == 2 and sys.argv[1] == "m"
sys.argv = [sys.argv[0]]
data = parsing.stdin2ndarray()
if not domax and not domed:
print np.abs(data[:,0]-data[:,1]).mean()
elif domax:
print np.abs(data[:,0]-data[:,1]).max()
elif domed:
print np.median(np.abs(data[:,0]-data[:,1]))