Basic Statistics of NumPy Array

Author: Al-mamun Sarkar Date: 2020-03-31 20:30:26

Basic Statistics of NumPy Array. The following shows basic statistics Mean, Median, Correlation coefficients, Standard deviation of a NumPy array of the Python NumPy module. 

 

import numpy as np

 

In [1]:

arr = np.array([1.2, 1.4, 1.9, 1.7, 1.6])
np_2d = np.array([[1.2, 1.4, 1.9, 1.7, 1.6], [37.7, 56.3, 62.8, 49.7, 62.5]])

 

In [2]:

np.mean(arr)

Out[2]:

1.5600000000000001

 

In [3]:

np.median(arr)

Out[3]:

1.6000000000000001

 

In [4]:

np_2d[0:1:,]

Out[4]:

array([[ 1.2,  1.4,  1.9,  1.7,  1.6]])

 

In [5]:

np.median(np_2d[0:1:,])

Out[5]:

1.6000000000000001

 

In [6]:

np.corrcoef(np_2d[:,0], np_2d[:,1])

Out[6]:

array([[ 1.,  1.],
       [ 1.,  1.]])

 

In [20]:

np.std(arr)

Out[20]:

0.24166091947189142