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

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

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


Recipe Objective

Statical analysis is very important part preprocessing. Have you tried to do it for matrix?

So this is the recipe on how we can can Calculate Mean, Variance and Std a Matrix or ndArray.

Step 1 - Importing Library

import numpy as np

We have only imported numpy which is needed.

Step 2 - Creating a matrix

We have created a matrix by using np.array with different values. matrixA = np.array([[1, 2, 3, 23], [4, 5, 6, 25], [7, 8, 9, 28], [10, 11, 12, 41]])

Step 3 - Finding Mean, Median, Variance and Standard Deviation

We have calculated mean, median , variance and standard deviation by using numpy functions for a matrix. print("Median: ", np.median(matrixA)) print("Mean: ", np.mean(matrixA)) print("Variance: ", np.var(matrixA)) print("Standrad Dev: ", np.std(matrixA)) So the output comes as

Median:  8.5

Mean:  12.1875

Variance:  118.27734375

Standrad Dev:  10.875538779757076

Relevant Projects

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Build a Collaborative Filtering Recommender System in Python
Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.