We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Mean, Var, and Std
- Discussions
Mean, Var, and Std
Mean, Var, and Std
Sort by
recency
|
432 Discussions
|
Please Login in order to post a comment
import numpy as np m,n=input().split() narr=np.array([list(map(int,input().split())) for i in range(int(n))]) print(np.mean(narr,axis=1)) print(np.var(narr,axis=0)) std=np.std(narr,axis=None) print(round(std,11))
Efficient code with lesser lines
import numpy as np n, m = map(int, input().split()) arr = [] for i in range(n): lm = list(map(int, input().split())) arr.append(lm) k = np.array(arr) print(np.mean(k, axis=1)) print(np.var(k, axis=0)) print(round(np.std(k), 11))
Simple code from my side..
import numpy as np
N,M = list(map(int, input().split())) ll=[] for i in range(N): arr=np.array(list(map(int, input().split()))) ll.append(arr) print(np.mean(ll, axis = 1)) print(np.var(ll, axis = 0)) print(np.round(np.std(ll),11))
import numpy as np
n, m = map(int, input().split())
arr = [list(map(int, input().split()[:m])) for _ in range(n)]
arr = np.array(arr)
print(np.mean(arr, axis = 1))
print(np.var(arr, axis = 0))
print(np.around(np.std(arr, axis = None),11))