-
Notifications
You must be signed in to change notification settings - Fork 1
4 Get Stats About Matrix
Süleyman Özarslan edited this page Sep 17, 2022
·
1 revision
func (matrix Matrix) Shape() map[string]intThe Shape function is used to get the number of rows and columns of a matrix. It returns a map with the values of "rows" and "cols".
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
rowNumber := mx.Shape()["rows"]
colNumber := mx.Shape()["cols"]func (matrix Matrix) Sum() float64Sum function returns the sum of the values in the matrix.
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
sum := mx.Sum() //45func (matrix Matrix) Mean() float64Mean returns the mean of the values in the matrix.
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
mean := mx.Mean() //5func (matrix Matrix) Variance() float64Variance function returns the variance of the values in the matrix.
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
variance := mx.Variance()func (matrix Matrix) Std() float64Std function returns the standard deviation of the values in the matrix.
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
sd := mx.Std()func (matrix Matrix) Max() float64Max function returns the max value of matrix
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
max := mx.Max()func (matrix Matrix) Min() float64Min function returns the min value of matrix
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
min := mx.Min()func (matrix Matrix) Det() float64Det function returns determinant of the matrix
mx := matrix.Matrix{{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
det := mx.Det()