Means |
Mean or central tendency of a data set is a measure of the middle value of the data set. Each of methods described in this section can be chosen as a measurement of the central tendency of the data items. These include averages, median and the midrange. They are calculated by combining the values from the set in a specific way and computing a single number as being the mean of the set. The most common method is the arithmetic mean but there are many other types of central tendency, such as median (which is used most often when the distribution of the values is skewed with some small numbers of very high values).
Hereinafter the following convention is used:
denotes data container element, i = 0..n-1. For vector, array of doubles and array of nullable doubles denotes an array element or vector element.
Operation | Description | Performance |
---|---|---|
mean | Returns the mean value of the data set. | |
arithmetic mean | Returns the arithmetic mean value of the data set. ArithmeticMean(Vector, Boolean) | |
geometric mean | Returns the geometric mean value of the data set. GeometricMean(Vector, Boolean) | |
quadratic mean | Returns the quadratic mean value of the data set. QuadraticMean(Vector, Boolean) | |
harmonic mean | Returns the harmonic mean value of the data set. | |
median | Returns median of the container's values. Median is the middle value of the given numbers or distribution in their ascending order.Median is the average value of the two middle elements when the size of the distribution is even. | |
midrange | Returns midrange of the container's values. |
The example of means implementation:
1using System; 2using FinMath.LinearAlgebra; 3using FinMath.Statistics; 4 5namespace FinMath.Samples 6{ 7 class VectorMeansSample 8 { 9 static void Main() 10 { 11 // Input parameters. 12 const Int32 observationsCount = 10; 13 14 // Generate input vector. 15 Vector vector = Vector.Random(observationsCount); 16 Console.WriteLine("Input vector:"); 17 Console.WriteLine(" " + vector.ToString("0.000")); 18 19 // Calculate and output different types of means. 20 Console.WriteLine("Results:"); 21 Console.WriteLine(" Mean: " + vector.Mean().ToString("0.00000")); 22 Console.WriteLine(" Arithmetic Mean: " + vector.ArithmeticMean().ToString("0.00000")); 23 Console.WriteLine(" Geometric Mean: " + vector.GeometricMean().ToString("0.00000")); 24 Console.WriteLine(" Harmonic Mean: " + vector.HarmonicMean().ToString("0.00000")); 25 Console.WriteLine(" Quadratic Mean: " + vector.QuadraticMean().ToString("0.00000")); 26 Console.WriteLine(" Median: " + vector.Median().ToString("0.00000")); 27 Console.WriteLine(" Midrange: " + vector.Midrange().ToString("0.00000")); 28 } 29 } 30}