Summation of Vectors and Matrices
Definition
Summation of a matrix or vector means adding elements either:
- Column-wise (most common in data analysis)
- Row-wise
A powerful method uses a vector of ones to compute sums and averages using matrix multiplication.
Key Points
-
A matrix ( ) has:
- ( ) rows (observations)
- ( ) columns (features)
-
To compute column sums:
where ( ) (row vector of size (1 \times n))
-
To compute column averages:
-
This works because:
- Multiplying by a vector of ones adds all rows together
Example / Code
Example 1: Matrix Summation and Average
Given:
Column sum:
Average:
Example 2: Using Ones Vector
Average:
General Formula
Practice Matrix
Average:
Explanation
-
The vector of ones acts like a “sum operator”.
-
When you multiply:
- Each column is summed independently
-
Dividing by ( ) gives the mean of each column
This method is widely used in:
- Machine Learning (feature averaging)
- Statistics (mean calculation)
- Data preprocessing
Output (if any)
- Output of summation: row vector
- Output of average: row vector
Common Mistakes
-
❌ Using wrong dimension for ones vector → Must match number of rows
-
❌ Dividing by wrong value → Always divide by number of rows ( ), not columns
-
❌ Arithmetic errors in summation → Double-check sums carefully
-
❌ Confusing row-wise vs column-wise operations
Short Exam Notes (very concise revision points)
- Column sum: ( )
- Column mean: ( )
- ( ): vector of ones
- Output is always
- Used for fast matrix-based averaging