Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

np.mean

import numpy as np

array1D = [20, 2, 7, 1, 34]
print(np.mean(array1D)) # 12.8 

array2D = [[14, 17, 12, 33, 44],  
           [15, 6, 27, 8, 19], 
           [23, 2, 54, 1, 4]] 
    
# mean of everything in the array, axis = None
print(np.mean(array2D)) # 18.6
    
# mean along the axis = 0 
print(np.mean(array2D, axis = 0)) # [17.333333, 8.333333, 31, 14, 22.333333]
   
# mean along the axis = 1 
print(np.mean(array2D, axis = 1)) # [24, 15, 16.8]
  
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
1+4 =