How to Calculate Mean, Variance and Std of a Matrix or ndArray?
0

How to Calculate Mean, Variance and Std of a Matrix or ndArray?

This recipe helps you Calculate Mean, Variance and Std of a Matrix or ndArray
In [1]:
## How to Calculate Mean, Variance and Std a Matrix or ndArray
def Kickstarter_Example_11():
    print()
    print(format('How to Calculate Mean, Variance and Std a Matrix or ndArray'
                 ,'*^72'))
    # Load library
    import numpy as np
    # Create matrix
    matrixA = np.array([[1, 2, 3, 23],
                       [4, 5, 6, 25],
                       [7, 8, 9, 28],
                       [10, 11, 12, 41]])
    # Return median, mean, variance and std
    print(); print("Median: ", np.median(matrixA))
    print(); print("Mean: ", np.mean(matrixA))
    print(); print("Variance: ", np.var(matrixA))
    print(); print("Standrad Dev: ", np.std(matrixA))
Kickstarter_Example_11()
******How to Calculate Mean, Variance and Std a Matrix or ndArray*******

Median:  8.5

Mean:  12.1875

Variance:  118.27734375

Standrad Dev:  10.875538779757076