For the music theory concept of "modes", seeMode (music).
Instatistics, themode is the value that appears most often in a set of data values.[1] IfX is a discrete random variable, the mode is the valuex at which theprobability mass functionP(X) takes its maximum value, i.e.,x =argmaxxi P(X =xi). In other words, it is the value that is most likely to be sampled.
The mode is not necessarily unique in a givendiscrete distribution since the probability mass function may take the same maximum value at several pointsx1,x2, etc. The most extreme case occurs inuniform distributions, where all values occur equally frequently.
Insymmetricunimodal distributions, such as thenormal distribution, the mean (if defined), median and mode all coincide. For samples, if it is known that they are drawn from a symmetric unimodal distribution, the sample mean can be used as an estimate of the population mode.
The mode of a sample is the element that occurs most often in the collection. For example, the mode of the sample [1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17] is 6. Given the list of data [1, 1, 2, 4, 4] its mode is not unique. A dataset, in such a case, is said to bebimodal, while a set with more than two modes may be described asmultimodal.
For a sample from a continuous distribution, such as [0.935..., 1.211..., 2.430..., 3.668..., 3.874...], the concept is unusable in its raw form, since no two values will be exactly the same, so each value will occur precisely once. In order to estimate the mode of the underlying distribution, the usual practice is to discretize the data by assigning frequency values tointervals of equal distance, as for making ahistogram, effectively replacing the values by the midpoints of theintervals they are assigned to. The mode is then the value where the histogram reaches its peak. For small or middle-sized samples the outcome of this procedure is sensitive to the choice of interval width if chosen too narrow or too wide; typically one should have a sizable fraction of the data concentrated in a relatively small number of intervals (5 to 10), while the fraction of the data falling outside these intervals is also sizable. An alternate approach iskernel density estimation, which essentially blurs point samples to produce a continuous estimate of the probability density function which can provide an estimate of the mode.
The followingMATLAB (orOctave) code example computes the mode of a sample:
X=sort(x);% x is a column vector datasetindices=find(diff([X,realmax])>0);% indices where repeated values change[modeL,i]=max(diff([0,indices]));% longest persistence length of repeated valuesmode=X(indices(i));
The algorithm requires as a first step to sort the sample in ascending order. It then computes the discrete derivative of the sorted list and finds the indices where this derivative is positive. Next it computes the discrete derivative of this set of indices, locating the maximum of this derivative of indices, and finally evaluates the sorted sample at the point where that maximum occurs, which corresponds to the last member of the stretch of repeated values.
Unlike mean and median, the concept of mode also makes sense for "nominal data" (i.e., not consisting ofnumerical values in the case of mean, or even of ordered values in the case of median). For example, taking a sample ofKorean family names, one might find that "Kim" occurs more often than any other name. Then "Kim" would be the mode of the sample. In any voting system where a plurality determines victory, a single modal value determines the victor, while a multi-modal outcome would require some tie-breaking procedure to take place.
Unlike median, the concept of mode makes sense for any random variable assuming values from avector space, including thereal numbers (a one-dimensional vector space) and theintegers (which can be considered embedded in the reals). For example, a distribution of points in theplane will typically have a mean and a mode, but the concept of median does not apply. The median makes sense when there is alinear order on the possible values. Generalizations of the concept of median to higher-dimensional spaces are thegeometric median and thecenterpoint.
For someprobability distributions, the expected value may be infinite or undefined, but if defined, it is unique. The mean of a (finite) sample is always defined. The median is the value such that the fractions not exceeding it and not falling below it are each at least 1/2. It is not necessarily unique, but never infinite or totally undefined. For a data sample it is the "halfway" value when the list of values is ordered in increasing value, where usually for a list of even length the numerical average is taken of the two values closest to "halfway". Finally, as said before, the mode is not necessarily unique. Certainpathological distributions (for example, theCantor distribution) have no defined mode at all.[citation needed][4] For a finite data sample, the mode is one (or more) of the values in the sample.
Assuming definedness, and for simplicity uniqueness, the following are some of the most interesting properties.
All three measures have the following property: If the random variable (or each value from the sample) is subjected to the linear oraffine transformation, which replacesX byaX +b, so are the mean, median and mode.
Except for extremely small samples, the mode is insensitive to "outliers" (such as occasional, rare, false experimental readings). The median is also very robust in the presence of outliers, while the mean is rather sensitive.
In continuousunimodal distributions the median often lies between the mean and the mode, about one third of the way going from mean to mode. In a formula, median ≈ (2 × mean + mode)/3. This rule, due toKarl Pearson, often applies to slightly non-symmetric distributions that resemble a normal distribution, but it is not always true and in general the three statistics can appear in any order.[5][6]
For unimodal distributions, the mode is within√3 standard deviations of the mean, and the root mean square deviation about the mode is between the standard deviation and twice the standard deviation.[7]
An example of askewed distribution ispersonal wealth: Few people are very rich, but among those some are extremely rich. However, many are rather poor.
A well-known class of distributions that can be arbitrarily skewed is given by thelog-normal distribution. It is obtained by transforming a random variableX having a normal distribution into random variableY =eX. Then the logarithm of random variableY is normally distributed, hence the name.
Taking the mean μ ofX to be 0, the median ofY will be 1, independent of thestandard deviation σ ofX. This is so becauseX has a symmetric distribution, so its median is also 0. The transformation fromX toY is monotonic, and so we find the mediane0 = 1 forY.
WhenX has standard deviation σ = 0.25, the distribution ofY is weakly skewed. Using formulas for thelog-normal distribution, we find:Indeed, the median is about one third on the way from mean to mode.
WhenX has a larger standard deviation,σ = 1, the distribution ofY is strongly skewed. NowHere,Pearson's rule of thumb fails.
It can be shown for a unimodal distribution that the median and the mean lie within (3/5)1/2 ≈ 0.7746 standard deviations of each other.[9] In symbols,
where is the absolute value.
A similar relation holds between the median and the mode: they lie within 31/2 ≈ 1.732 standard deviations of each other:
Pearson uses the termmode interchangeably withmaximum-ordinate. In a footnote he says, "I have found it convenient to use the termmode for the abscissa corresponding to the ordinate of maximum frequency."
^Morrison, Kent (1998-07-23)."Random Walks with Decreasing Steps"(PDF).Department of Mathematics, California Polytechnic State University. Archived fromthe original(PDF) on 2015-12-02. Retrieved2007-02-16.
^Basu, Sanjib; Dasgupta, Anirban (1997). "The mean, median, and mode of unimodal distributions: a characterization".Theory of Probability & Its Applications.41 (2):210–223.doi:10.1137/S0040585X97975447.