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
|
441 Discussions
|
Please Login in order to post a comment
Had to round numpy.std value off to the 11th decimal ( i know i'm not the first one to find that out ;) )
For Python3
It itsnt mentioned to round off the std value to 11 decimals. So, use round function just to match the answer.
import numpy N, M = map(int, input().strip().split()) my_arr = numpy.array([input().strip().split()[:M] for _ in range(N)], dtype=numpy.float_) print(numpy.mean(my_arr, axis=1)) print(numpy.var(my_arr, axis=0)) print(round(numpy.std(my_arr, axis = None), 11))
import numpy
n , m = map(int,input().split())
arrayList = [] for i in range(n): arrayList.append(list(map(int,input().split())))
my_array = numpy.array(arrayList) print(numpy.mean(my_array, axis = 1)) print(numpy.var(my_array, axis = 0)) print(round(numpy.std(my_array, axis = None), 11))