LibraryStatistical Analysis: Mean, Median, Standard Deviation, Variance

Statistical Analysis: Mean, Median, Standard Deviation, Variance

Learn about Statistical Analysis: Mean, Median, Standard Deviation, Variance as part of MATLAB Programming for Engineering and Scientific Research

Understanding Core Statistical Measures in MATLAB

In engineering and scientific research, understanding the central tendency and spread of your data is crucial. MATLAB provides powerful functions to calculate key statistical measures like the mean, median, standard deviation, and variance. This module will guide you through these concepts and how to implement them in MATLAB.

Mean: The Average Value

The mean, often called the average, is calculated by summing all values in a dataset and dividing by the number of values. It represents the central point of the data. In MATLAB, the

code
mean()
function computes this.

What is the mathematical definition of the mean?

The sum of all values in a dataset divided by the count of values.

Median: The Middle Value

The median is the middle value in a dataset that has been ordered from least to greatest. If there's an even number of values, the median is the average of the two middle values. The median is less affected by outliers than the mean. MATLAB uses the

code
median()
function.

The median is a robust statistic, meaning it's less sensitive to extreme values (outliers) compared to the mean.

Variance: Measuring Data Spread

Variance quantifies how spread out the data points are from the mean. It's calculated as the average of the squared differences from the mean. A higher variance indicates that data points are further from the mean and from each other. MATLAB's

code
var()
function calculates variance.

Variance is the average of the squared differences from the mean. For a dataset X = {x1, x2, ..., xn} and mean μ, the population variance (σ²) is Σ(xi - μ)² / N. The sample variance (s²) uses N-1 in the denominator for an unbiased estimate. MATLAB's var() function by default calculates the sample variance.

📚

Text-based content

Library pages focus on text content

Standard Deviation: The Square Root of Variance

The standard deviation is the square root of the variance. It's often preferred because it's in the same units as the original data, making it easier to interpret the spread. A low standard deviation indicates that data points are clustered around the mean, while a high standard deviation indicates they are more spread out. Use the

code
std()
function in MATLAB.

MeasurePurposeMATLAB FunctionSensitivity to Outliers
MeanCentral tendency (average)mean()High
MedianCentral tendency (middle value)median()Low
VarianceMeasure of data spread (squared units)var()High
Standard DeviationMeasure of data spread (original units)std()High

Practical Application in MATLAB

Let's consider a simple example. Suppose you have a vector of sensor readings:

code
sensorData = [22.5, 23.1, 22.8, 23.5, 22.9, 23.2, 22.7, 23.0, 22.6, 23.3];

You can calculate the statistics as follows:

code
avgValue = mean(sensorData);
code
medianValue = median(sensorData);
code
varianceValue = var(sensorData);
code
stdDevValue = std(sensorData);

These values will give you a clear understanding of the typical reading and how much the readings vary.

Which MATLAB function would you use to find the middle value of an ordered dataset?

median()

Learning Resources

MATLAB Documentation: Mean, Median, Mode, and Standard Deviation(documentation)

Official MathWorks documentation covering the `mean`, `median`, `mode`, and `std` functions, with examples.

MATLAB Documentation: Variance(documentation)

Detailed explanation of the `var` function for calculating variance in MATLAB, including sample vs. population variance.

Khan Academy: Mean, Median, and Mode(video)

A foundational video explaining the concepts of mean, median, and mode with clear examples.

Khan Academy: Standard Deviation and Variance(video)

An excellent visual explanation of variance and standard deviation, including how they measure data spread.

Statistics Tutorial: Measures of Central Tendency(blog)

A comprehensive guide to understanding mean, median, and mode, with practical applications.

Statistics Tutorial: Measures of Dispersion(blog)

Explains variance and standard deviation, detailing how they quantify the spread of data.

Understanding the Difference Between Mean, Median, and Mode(blog)

A clear, accessible explanation of the three main measures of central tendency and when to use each.

MATLAB Answers: Calculating Statistics on Data(documentation)

A practical example from MathWorks demonstrating how to perform statistical analysis on data in MATLAB.

Wikipedia: Mean(wikipedia)

The Wikipedia page for 'Mean' provides a detailed mathematical definition and properties.

Wikipedia: Standard Deviation(wikipedia)

Comprehensive information on standard deviation, its calculation, and its applications in statistics.