-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmean_var_std.py
More file actions
17 lines (14 loc) · 897 Bytes
/
Copy pathmean_var_std.py
File metadata and controls
17 lines (14 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import numpy as np
def calculate(list):
if len(list) != 9:
raise ValueError("List must contain nine numbers.")
matrix = np.array(list).reshape(3, 3)
calculations = {
'mean': [np.mean(matrix, axis=0).tolist(), np.mean(matrix, axis=1).tolist(), np.mean(matrix).tolist()],
'variance': [np.var(matrix, axis=0).tolist(), np.var(matrix, axis=1).tolist(), np.var(matrix).tolist()],
'standard deviation': [np.std(matrix, axis=0).tolist(), np.std(matrix, axis=1).tolist(), np.std(matrix).tolist()],
'max': [np.max(matrix, axis=0).tolist(), np.max(matrix, axis=1).tolist(), np.max(matrix).tolist()],
'min': [np.min(matrix, axis=0).tolist(), np.min(matrix, axis=1).tolist(), np.min(matrix).tolist()],
'sum': [np.sum(matrix, axis=0).tolist(), np.sum(matrix, axis=1).tolist(), np.sum(matrix).tolist()]
}
return calculations