Descriptive Statistics

Descriptive statistics refers to properties of distributions, such as location, dispersion, and shape. The functions described here compute descriptive statistics of lists of data. You can calculate some of the standard descriptive statistics for various known distributions by using the functions described in "Continuous Distributions" and "Discrete Distributions".

The statistics are calculated assuming that each value of data (Subscript[x, i]) has probability equal to (1/n), where n is the number of elements in the data.

Location statistics.

Location statistics describe where the data is located. The most common functions include measures of central tendency like the mean, median, and mode. (RefLink[Quantile, paclet:ref/Quantile])[data,q] gives the location before which (100q) percent of the data lie. In other words, (RefLink[Quantile, paclet:ref/Quantile]) gives a value z such that the probability that ((Subscript[x, i])<z) is less than or equal to q and the probability that ((Subscript[x, i])≤z) is greater than or equal to q.

Here is a dataset:

data={6.5,3.8,6.6,5.7,6.0,6.4,5.3}

This finds the mean and median of the data:

{Mean[data], Median[data]}

This is the mean when the smallest entry in the list is excluded. (RefLink[TrimmedMean, paclet:ref/TrimmedMean]) allows you to describe the data with removed outliers:

TrimmedMean[data,{(1/7),0}]

Dispersion statistics.

Dispersion statistics summarize the scatter or spread of the data. Most of these functions describe deviation from a particular location. For instance, variance is a measure of deviation from the mean, and standard deviation is just the square root of the variance.

This gives an unbiased estimate for the variance of the data with n-1 as the divisor:

Variance[data]

This compares three types of deviation:

{StandardDeviation[data],MeanDeviation[data],MedianDeviation[data]}

Covariance and correlation statistics.

Covariance is the multivariate extension of variance. For two vectors of equal length, the covariance is a number. For a single matrix m, the i,j(^th) element of the covariance matrix is the covariance between the i(^th) and j(^th) columns of m. For two matrices (Subscript[m, 1]) and (Subscript[m, 2]), the i,j(^th) element of the covariance matrix is the covariance between the i(^th) column of (Subscript[m, 1]) and the j(^th) column of (Subscript[m, 2]).

While covariance measures dispersion, correlation measures association. The correlation between two vectors is equivalent to the covariance between the vectors divided by the standard deviations of the vectors. Likewise, the elements of a correlation matrix are equivalent to the elements of the corresponding covariance matrix scaled by the appropriate column standard deviations.

This gives the covariance between data and a random vector:

Covariance[data,RandomReal[1,Length[data]]]

Here is a random matrix:

m=RandomReal[10,{20,2}]

This is the correlation matrix for the matrix m:

Correlation[m]

This is the covariance matrix:

Covariance[m]

Scaling the covariance matrix terms by the appropriate standard deviations gives the correlation matrix:

With[{sd=StandardDeviation[m]},
Transpose[Transpose[%/sd]/sd]]

Shape statistics.

You can get some information about the shape of a distribution using shape statistics. Skewness describes the amount of asymmetry. Kurtosis measures the concentration of data around the peak and in the tails versus the concentration in the flanks.

(RefLink[Skewness, paclet:ref/Skewness]) is calculated by dividing the third central moment by the cube of the population standard deviation. (RefLink[Kurtosis, paclet:ref/Kurtosis]) is calculated by dividing the fourth central moment by the square of the population variance of the data, equivalent to (RefLink[CentralMoment, paclet:ref/CentralMoment])[data,2]. (The population variance is the second central moment, and the population standard deviation is its square root.)

(RefLink[QuartileSkewness, paclet:ref/QuartileSkewness]) is calculated from the quartiles of data. It is equivalent to ((Subscript[q, 1])-2(Subscript[q, 2])+(Subscript[q, 3]))/((Subscript[q, 3])-(Subscript[q, 1])), where (Subscript[q, 1]), (Subscript[q, 2]), and (Subscript[q, 3]) are the first, second, and third quartiles respectively.

Here is the second central moment of the data:

CentralMoment[data,2]

A negative value for skewness indicates that the distribution underlying the data has a long left-sided tail:

Skewness[data]

Expected values.

The expectation or expected value of a function f is (1/n)(∑_(i=1)^n)f((Subscript[x, i])) for the list of values (Subscript[x, 1]), (Subscript[x, 2]), …, (Subscript[x, n]). Many descriptive statistics are expectations. For instance, the mean is the expected value of x, and the r(^th) central moment is the expected value of (((x-(OverBar[x])))^r) where (OverBar[x]) is the mean of the (Subscript[x, i]).

Here is the expected value of the (RefLink[Log, paclet:ref/Log]) of the data:

Expectation[Log[x],x\[Distributed]data]