refactored how statistical computations on matrices are performed.