Means And Sums |
Mean or central tendency of a data set is a measure of the middle value of the data set.
Hereinafter the following convention is used:
denotes data container element, i = 0..n-1. In case of matrix denotes matrix row. Matrix columns corresponds to variables, rows correspond to observations. Mean or sum method for matrix calculates value for each variable among its observations. Therefore, for matrix argument the result will be of vector type.
Operation | Description | Performance |
---|---|---|
mean | Returns the mean value among the rows. | |
sum | Calculates sum of rows. |
The example of mean and sum of matrix data:
1using System; 2using FinMath.LinearAlgebra; 3using FinMath.Statistics; 4 5namespace FinMath.Samples 6{ 7 class MatrixMeansSample 8 { 9 static void Main() 10 { 11 // Input parameters. 12 const Int32 observationsCount = 10; 13 const Int32 seriesCount = 5; 14 Matrix matrix = Matrix.Random(observationsCount, seriesCount); 15 Console.WriteLine("Transposed input matrix:"); 16 Console.WriteLine(matrix.ToString("0.000")); 17 Console.WriteLine(); 18 19 // Calculate and output results. 20 Console.WriteLine("Means of series: " + matrix.Mean().ToString("0.000")); 21 Console.WriteLine("Sums of series: " + matrix.Sum().ToString("0.000")); 22 } 23 } 24}