Click or drag to resize

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:

DSxi denotes data container element, i = 0..n-1. For vector, array of doubles and array of nullable doubles DSxi denotes an array element or vector element.

Methods

Operation

Description

Performance

mean

Returns the mean value of the data set.

DSMean

StaticMean(Vector, Boolean)

StaticMean(IEnumerableDouble, Boolean)

StaticMean(IEnumerableNullableDouble, Boolean)

arithmetic mean

Returns the arithmetic mean value of the data set.

DSAMean

StaticArithmeticMean(Vector, Boolean)

StaticArithmeticMean(IEnumerableDouble, Boolean)

StaticArithmeticMean(IEnumerableNullableDouble, Boolean)

geometric mean

Returns the geometric mean value of the data set.

DSGMean

StaticGeometricMean(Vector, Boolean)

StaticGeometricMean(IEnumerableDouble, Boolean)

StaticGeometricMean(IEnumerableNullableDouble, Boolean)

quadratic mean

Returns the quadratic mean value of the data set.

DSQMean

StaticQuadraticMean(Vector, Boolean)

StaticQuadraticMean(IEnumerableDouble, Boolean)

StaticQuadraticMean(IEnumerableNullableDouble, Boolean)

harmonic mean

Returns the harmonic mean value of the data set.

DSHMean

StaticHarmonicMean(Vector, Boolean)

StaticHarmonicMean(IEnumerableDouble, Boolean)

StaticHarmonicMean(IEnumerableNullableDouble, Boolean)

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.

StaticMedian(Vector, Boolean)

StaticMedian(IEnumerableDouble, Boolean)

StaticMedian(IEnumerableNullableDouble, Boolean)

midrange

Returns midrange of the container's values.

DSMidrange

StaticMidrange(Vector, Boolean)

StaticMidrange(IEnumerableDouble, Boolean)

StaticMidrange(IEnumerableNullableDouble, Boolean)

Code Sample

The example of means implementation:

C#
 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}

See Also