Contenido principal

Compute Mean, Median, and Other Descriptive Statistics

You can use basic descriptive statistics to interpret and summarize data. Descriptive statistics help you understand important features of your data, such as:

  • What a typical value is (central tendency)

  • Which values are unusually high or low (extremes)

  • How widely values are spread (variability)

You can compute a specific statistic using its corresponding MATLAB function, or you can compute multiple statistics for an overview of your data using the summary function. For information about computing statistics interactively, see Explore Basic Statistics on 2-D Plot.

Measure Central Tendency with Mean, Median, and Mode

Central tendency refers to the typical or central value in a data set. Common measures of central tendency are the mean, median, and mode.

For example, create a vector of sample test scores.

scores = [72 88 91 85 85 90 76 95];

Compute the average of your data using the mean function.

meanScore = mean(scores)
meanScore = 
85.2500

Find the central value of a sorted version of your data using the median function.

medianScore = median(scores)
medianScore = 
86.5000

Identify the most frequently occurring value in your data using the mode function.

modeScore = mode(scores)
modeScore = 
85

Identify Data Extremes with Minimum and Maximum

Determining the lowest and highest values in your data can help you understand the scale and spread of your data and detect outliers or errors. You can compute the lowest and highest values separately using the min and max functions, or you can compute both values at the same time using the bounds function.

For example, find the lowest and highest test scores.

lowestScore = min(scores)
lowestScore = 
72
highestScore = max(scores)
highestScore = 
95
[lowestScore,highestScore] = bounds(scores)
lowestScore = 
72
highestScore = 
95

Find the k Lowest or Highest Values

To understand whether your data has multiple unusually low or high data points, you can examine the k lowest or highest values. To find these values, use the mink and the maxk functions.

For example, find the three lowest test scores and three highest test scores.

k = 3;
lowest3Scores = mink(scores,k)
lowest3Scores = 1×3

    72    76    85

highest3Scores = maxk(scores,k)
highest3Scores = 1×3

    95    91    90

Describe Data Spread with Standard Deviation and Variance

Measures of spread, such as standard deviation and variance, describe how much your data values deviate from the mean. These statistics provide insights about the distribution of your data, such as whether most values are close to the mean or whether the values vary widely. To find these values, use the std and var functions.

For example, find the standard deviation and variance of the sample test scores.

scoreStd = std(scores)
scoreStd = 
7.7414
scoreVar = var(scores)
scoreVar = 
59.9286

Summarize Data with One Function Call

To generate a high-level overview of your data, use the summary function. The summary function computes several common statistics for your data and displays the results in a concise overview. Using summary is convenient when you want to see multiple statistics at a time without calling each statistics function individually.

For example, generate a summary of the sample test scores.

summary(scores)
scores: 1×8 double

    NumMissing            0  
    Min                  72  
    Median          86.5000  
    Max                  95  
    Mean            85.2500  
    Std              7.7414  

See Also

Functions

Topics