Mean, Var, and Std

Sort by

recency

|

432 Discussions

|

  • + 0 comments

    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

  • + 0 comments

    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))

  • + 0 comments

    Simple code from my side..

    import numpy
    
    a , b = map(int,input().split())
    
    
    arrayList = []
    for i in range(a):
        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))
    
  • + 0 comments

    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))

  • + 0 comments

    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))