Basic Statistics

Basic descriptive statistics operations.

Given a list with n elements (Subscript[x, i]), the mean (RefLink[Mean, paclet:ref/Mean])[list] is defined to be μ(x)==(OverBar[x])==∑(Subscript[x, i])/n.

The variance (RefLink[Variance, paclet:ref/Variance])[list] is defined to be var(x)==(σ^2)(x)==∑((((Subscript[x, i])-μ(x)))^2)/(n-1), for real data. (For complex data var(x)==(σ^2)(x)==∑((Subscript[x, i])-μ(x))((OverBar[(Subscript[x, i])-μ(x)]))/(n-1).)

The standard deviation (RefLink[StandardDeviation, paclet:ref/StandardDeviation])[list] is defined to be σ(x)==(Sqrt[var(x)]).

If the elements in list are thought of as being selected at random according to some probability distribution, then the mean gives an estimate of where the center of the distribution is located, while the standard deviation gives an estimate of how wide the dispersion in the distribution is.

The median (RefLink[Median, paclet:ref/Median])[list] effectively gives the value at the halfway point in the sorted version of list. It is often considered a more robust measure of the center of a distribution than the mean, since it depends less on outlying values.

The q(^th) quantile (RefLink[Quantile, paclet:ref/Quantile])[list,q] effectively gives the value that is q of the way through the sorted version of list.

For a list of length n, the Wolfram Language defines (RefLink[Quantile, paclet:ref/Quantile])[list,q] to be s[[(RefLink[Ceiling, paclet:ref/Ceiling])[n q]]], where s is (RefLink[Sort, paclet:ref/Sort])[list,(RefLink[Less, paclet:ref/Less])].

There are, however, about 10 other definitions of quantile in use, all potentially giving slightly different results. The Wolfram Language covers the common cases by introducing four quantile parameters in the form (RefLink[Quantile, paclet:ref/Quantile])[list,q,{{a,b},{c,d}}]. The parameters a and b in effect define where in the list should be considered a fraction q of the way through. If this corresponds to an integer position, then the element at that position is taken to be the q(^th) quantile. If it is not an integer position, then a linear combination of the elements on either side is used, as specified by c and d.

The position in a sorted list s for the q(^th) quantile is taken to be k==a+(n+b) q. If k is an integer, then the quantile is (Subscript[s, k]). Otherwise, it is (Subscript[s, ⌊k⌋])+((Subscript[s, ⌈k⌉])-(Subscript[s, ⌊k⌋]))(c+d(k-⌊k⌋)), with the indices taken to be 1 or n if they are out of range.

Common choices for quantile parameters.

Whenever d==0, the value of the q(^th) quantile is always equal to some actual element in list, so that the result changes discontinuously as q varies. For d==1, the q(^th) quantile interpolates linearly between successive elements in list. (RefLink[Median, paclet:ref/Median]) is defined to use such an interpolation.

Note that (RefLink[Quantile, paclet:ref/Quantile])[list,q] yields quartiles when q==m/4 and percentiles when q==m/100.

Handling multidimensional data.

Sometimes each item in your data may involve a list of values. The basic statistics functions in the Wolfram Language automatically apply to all corresponding elements in these lists.

This separately finds the mean of each "column" of data:

Mean[{{x1,y1},{x2,y2},{x3,y3}}]

Note that you can extract the elements in the i(^th) "column" of a multidimensional list using list[[(RefLink[All, paclet:ref/All]),i]].