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