Mean
The mean is one of the simplest and most useful ideas in statistics. It gives us a single value that represents the average of a group of numbers. AI and machine learning use averages in many different calculations and data-processing tasks.
The mean tells us the average value of a group of numbers.
Add all the values together and divide the total by the number of values.
What Is the Mean?
The mean is another word for the average.
Suppose five students get these scores:
60, 70, 80, 90, 100
We want to find the average score.
First, add all the numbers:
60 + 70 + 80 + 90 + 100 = 400
There are 5 values, so divide by 5:
400 / 5 = 80
Therefore:
Mean = 80
The Mean Formula
The formula is simple:
Mean = Sum of all values
-------------------
Number of values
For example:
Values: 10, 20, 30 Sum: 10 + 20 + 30 = 60 Number of values: 3 Mean: 60 / 3 = 20
So the mean is:
Mean = 20
Why Do We Need the Mean?
Imagine you have thousands of numbers. Looking at every individual value would be difficult.
The mean gives us one number that summarizes the data.
Data:
72
75
81
79
88
90
76
84
...
↓
Calculate Mean
↓
Average = one summary value
Instead of looking at every value separately, we can quickly understand the general level of the data.
Real-World Example
Imagine an online store wants to understand the average amount customers spend in an order.
Suppose five orders are:
₹500 ₹700 ₹800 ₹1,000 ₹1,500
Add them:
500 + 700 + 800 + 1000 + 1500 = ₹4,500
There are 5 orders:
₹4,500 / 5 = ₹900
So the average order value is:
Mean order value = ₹900
This gives the business a quick summary of customer spending.
Mean in AI
AI systems work with large amounts of numerical data. The mean can help summarize that data.
For example, suppose an AI system receives five temperature measurements:
25 27 26 28 24
The mean temperature is:
(25 + 27 + 26 + 28 + 24) / 5 = 130 / 5 = 26
So the AI can use:
Average temperature = 26°C
This gives the system a simple summary of the measurements.
Mean in Machine Learning Data
Machine learning datasets often contain numerical features.
Imagine a dataset containing the ages of customers:
20 25 30 35 40
The mean age is:
(20 + 25 + 30 + 35 + 40) / 5 = 150 / 5 = 30
Therefore:
Mean age = 30
The mean can help us understand the general characteristics of a dataset.
Mean and Data Preprocessing
Mean is also important when preparing data for machine learning.
One common technique is called mean imputation. This means replacing a missing numerical value with the mean of the available values.
For example:
Age: 20 25 ? 35 40
First calculate the mean of the available values:
(20 + 25 + 35 + 40) / 4 = 120 / 4 = 30
We could replace the missing value with 30:
20 25 30 35 40
This is only one simple technique for handling missing data. In real machine learning projects, the best method depends on the dataset and problem.
A Problem With the Mean
The mean is useful, but it has an important weakness: extreme values can strongly affect it.
Consider these salaries:
₹20,000 ₹22,000 ₹24,000 ₹25,000 ₹2,00,000
The last value is much larger than the others.
Calculate the mean:
(20,000 + 22,000 + 24,000 + 25,000 + 2,00,000) / 5 = ₹2,91,000 / 5 = ₹58,200
The mean is ₹58,200, even though four of the five people earn between ₹20,000 and ₹25,000.
This is why we cannot blindly use the mean for every dataset.
Mean vs Median
This is where the median becomes useful.
Using the same salaries:
₹20,000 ₹22,000 ₹24,000 ₹25,000 ₹2,00,000
The middle value is:
₹24,000
So:
Mean = ₹58,200 Median = ₹24,000
The mean was pulled upward by the extremely large salary, while the median stayed near the typical values.
We will study the median in the next lesson.
Mean in Python
We can calculate a mean directly in Python.
numbers = [10, 20, 30, 40, 50] mean = sum(numbers) / len(numbers) print(mean)
Output:
30.0
Here:
sum(numbers) → adds all values len(numbers) → counts how many values exist sum / len → calculates the mean
This is exactly the same mathematical process we performed manually.
Mean and AI: The Bigger Picture
Mean is not an AI algorithm by itself. It is a basic statistical tool that becomes useful inside larger AI and machine learning workflows.
Raw Data
↓
Understand the data
↓
Calculate statistics
↓
Prepare the data
↓
Train AI / ML model
↓
Make predictions
Mean can therefore be part of the data analysis and preprocessing stage before a model is trained.
The Main Idea
If you remember only one thing from this lesson, remember this:
Mean = Total of all values
-------------------
Number of values
For example:
Numbers: 5, 10, 15 Total: 5 + 10 + 15 = 30 Count: 3 Mean: 30 / 3 = 10
The mean gives us a single number representing the average of the data.
Mean is the average of a group of numbers.
Add all the values together and divide by the number of values. Mean is useful for summarizing data and is used in many statistics and machine learning workflows. However, extreme values can strongly affect the mean, so we should not use it blindly for every dataset.