Mean-Variance-Standard Deviation Calculator project:
A Python project that uses NumPy to calculate statistical measures from a list of nine numbers arranged into a 3×3 matrix.
-
Calculates:
- Mean
- Variance
- Standard Deviation
- Maximum Value
- Minimum Value
- Sum
-
Returns results for:
- Each column
- Each row
- The entire matrix
- Python
- NumPy
mean-variance-standard-deviation-calculator/
│
├── mean_var_std.py
├── test_module.py
└── README.md
The program accepts a list containing exactly nine numbers.
Example Input:
calculate([1, 2, 3, 4, 5, 6, 7, 8, 9])The list is converted into the following matrix:
[[1 2 3]
[4 5 6]
[7 8 9]]
The program then calculates statistical values across rows, columns, and the entire matrix.
{
'mean': [[4.0, 5.0, 6.0], [2.0, 5.0, 8.0], 5.0],
'variance': [[6.0, 6.0, 6.0],
[0.6666666666666666, 0.6666666666666666, 0.6666666666666666],
6.666666666666667],
'standard_deviation': [[2.449489742783178, 2.449489742783178, 2.449489742783178],
[0.816496580927726, 0.816496580927726, 0.816496580927726],
2.581988897471611],
'max': [[7, 8, 9], [3, 6, 9], 9],
'min': [[1, 2, 3], [1, 4, 7], 1],
'sum': [[12, 15, 18], [6, 15, 24], 45]
}The function requires exactly nine numbers.
Example:
calculate([1, 2, 3])Output:
ValueError: List must contain nine numbers.Through this project, I practiced:
- NumPy arrays and matrix operations
- Statistical calculations using NumPy
- Data reshaping with
reshape() - Error handling in Python
- Writing clean and reusable functions
Bhavana Ramaswaram