Open almost any statistics book or machine learning paper, and within a page you'll meet a big jagged symbol: Σ. It's the Greek capital letter sigma, and for many beginners it's the moment the maths starts to look scary.
It shouldn't be. Σ means one thing: add up. That's it. It's a compact way to write "add these numbers together", the same thing Python's sum() does, or a for loop with a running total. Once you can read it, formulas for the mean, variance, linear regression, loss functions and softmax all become readable.
This lesson shows how to read Σ notation piece by piece, works through examples by hand, covers the few rules for simplifying sums, explains double sums, and translates every formula into Python.
What you need first: maths notation and symbols and variables and expressions.
Key terms
- Σ (sigma): the summation symbol, meaning "add up".
- Index (or counter): the letter that changes each step, usually i, j or k.
- Lower limit: the index's starting value, written below Σ.
- Upper limit: the index's last value, written above Σ.
- Term: the expression after Σ that gets calculated for each index value.
Reading Σ, piece by piece
A sum has four parts:
Σᵢ₌₁ⁿ xᵢ
Written out in full, the 1 sits underneath the Σ (as i = 1) and the n sits on top.
| Part | Here | Meaning |
|---|---|---|
| Σ | Σ | add up |
| below | i = 1 | start the counter i at 1 |
| above | n | stop when i reaches n |
| after | xᵢ | for each i, take the value xᵢ |
Read aloud: "the sum of x i, for i from 1 to n". Written out: x₁ + x₂ + x₃ + … + xₙ.
It's a loop in a single symbol:
| Maths | Python |
|---|---|
| Σᵢ₌₁ⁿ xᵢ | total = 0 then for i in range(n): total += x[i] |
(Python counts from 0, maths usually from 1; see subscripts and indices.)
Worked examples
Σᵢ₌₁⁵ i: the term is just i, so add the counter itself:
1 + 2 + 3 + 4 + 5 = 15
Σᵢ₌₁⁴ i²: square each counter value, then add:
1² + 2² + 3² + 4² = 1 + 4 + 9 + 16 = 30
Σᵢ₌₁³ (2i + 1): calculate the term for i = 1, 2, 3:
(2 + 1) + (4 + 1) + (6 + 1) = 3 + 5 + 7 = 15
Σₖ₌₃⁵ 10: the term doesn't contain k, so it's just 10 each time, for k = 3, 4, 5:
10 + 10 + 10 = 30
The method is always the same:
- List the index values, from the lower limit to the upper limit.
- Calculate the term for each.
- Add them up.
Summing data
In statistics, the term is usually a data value. If the data is x = [4, 8, 15, 16, 23], then x₁ = 4, x₂ = 8, and so on, with n = 5:
Σᵢ₌₁⁵ xᵢ = 4 + 8 + 15 + 16 + 23 = 66
x = [4, 8, 15, 16, 23]
total = 0
for i in range(len(x)):
total += x[i]
print(total)
print(sum(x))
print(sum(i ** 2 for i in range(1, 5)))
66
66
30
The loop is Σ spelled out; sum() does it in one go. The last line is Σᵢ₌₁⁴ i², written almost exactly like the maths.
Common shorthand
Books often leave out parts when they're obvious:
- Σᵢ xᵢ: sum over every i, all the data.
- Σ x: the same, even shorter.
- Σᵢ₌₁ⁿ is often printed beside the Σ instead of above and below it, especially in a line of text.
If the limits are missing, assume "all the data".
Formulas you can now read
The mean
x̄ = (1/n) Σᵢ₌₁ⁿ xᵢ
"Add up all the values, then divide by how many." For the data above: 66/5 = 13.2.
The sum of squared deviations
Σᵢ₌₁ⁿ (xᵢ − x̄)²
For each value, subtract the mean, square it, then add them all. This measures spread, and it's the heart of the variance and standard deviation you'll meet in the Statistics course.
import numpy as np
x = np.array([4, 8, 15, 16, 23])
print(x.sum(), x.mean())
print(((x - x.mean()) ** 2).sum())
66 13.2
218.8
In NumPy, the term is written for the whole array at once, then .sum() adds it up: ((x - x.mean()) ** 2).sum() reads almost left to right like Σ(xᵢ − x̄)².
A weighted total
Σᵢ wᵢxᵢ: multiply each value by its weight, then add. A final grade with coursework worth 30%, a project 20% and an exam 50%, scoring 70, 85 and 60: 0.3(70) + 0.2(85) + 0.5(60) = 21 + 17 + 30 = 68.
This exact pattern is a linear regression prediction: ŷ = b + Σⱼ wⱼxⱼ, each feature times its weight, added up.
The rules of sums
Three rules let you simplify and rearrange sums. Each follows from ordinary addition.
1. Constants come out
Σ c·xᵢ = c Σ xᵢ
Doubling every value then adding is the same as adding then doubling: 2·4 + 2·8 = 2(4 + 8).
2. Sums split
Σ (xᵢ + yᵢ) = Σ xᵢ + Σ yᵢ
You can add in any order.
3. Summing a constant
Σᵢ₌₁ⁿ c = n·c
Adding c, n times, is n × c. That's why Σᵢ₌₁ⁿ x̄ = n·x̄.
But: Σ xᵢ² ≠ (Σ xᵢ)² and Σ xᵢyᵢ ≠ (Σ xᵢ)(Σ yᵢ). Squaring each value and adding is not the same as adding then squaring: 1² + 2² = 5, but (1 + 2)² = 9.
y = np.array([1, 0, 2, 1, 3])
print((3 * x).sum(), 3 * x.sum())
print((x + y).sum(), x.sum() + y.sum())
print((x ** 2).sum(), x.sum() ** 2)
198 198
73 73
1090 4356
The first two rules hold; the last line shows the squares don't.
Why these rules matter: a neat result
Using the rules, Σ(xᵢ − x̄) = Σxᵢ − Σx̄ = n·x̄ − n·x̄ = 0. Deviations from the mean always add to zero, which is exactly why statisticians square them before adding. Rules like this are how almost every statistics formula is derived.
Double sums
Data in a table has rows and columns, so you sometimes need two counters:
Σᵢ Σⱼ xᵢⱼ
Read it as: for each row i, add up across every column j; then add the row totals. In other words: add every cell in the table.
table = np.array([[1, 2, 3],
[4, 5, 6]])
print(table.sum())
print(table.sum(axis=0))
print(table.sum(axis=1))
21
[5 7 9]
[ 6 15]
table.sum()is the double sum, every cell: 21.sum(axis=0)sums down each column: Σᵢ xᵢⱼ for each j.sum(axis=1)sums across each row: Σⱼ xᵢⱼ for each i.
Matrix multiplication, the engine of the Linear algebra course and of neural networks, is built from sums exactly like this.
Σ in machine learning formulas
| Formula | What the Σ adds up |
|---|---|
| Mean squared error: (1/n) Σ (yᵢ − ŷᵢ)² | the squared error of every example |
| Linear model: ŷ = b + Σⱼ wⱼxⱼ | each feature times its weight |
| Softmax: e^(zᵢ) / Σⱼ e^(zⱼ) | the exponentials of every class score |
| Log loss: −(1/n) Σ log(pᵢ) | the log-probability of every correct answer |
The last lesson of this module reads the first one in full: how to read the mean squared error formula.
Practice
- Work out Σᵢ₌₁⁴ 3i.
Show the answer
3 + 6 + 9 + 12 = 30. (Or 3 × Σi = 3 × 10.)
- Work out Σₖ₌₂⁵ (k − 1)².
Show the answer
k = 2, 3, 4, 5 gives 1 + 4 + 9 + 16 = 30.
- Write 2 + 4 + 6 + 8 + 10 in Σ notation.
Show the answer
Σᵢ₌₁⁵ 2i.
- For data x = [2, 5, 9], calculate Σxᵢ, Σxᵢ² and (Σxᵢ)².
Show the answer
Σxᵢ = 16. Σxᵢ² = 4 + 25 + 81 = 110. (Σxᵢ)² = 256.
- Translate (1/n) Σᵢ₌₁ⁿ |xᵢ − x̄| into NumPy.
Show the answer
np.abs(x - x.mean()).mean(): the mean absolute deviation. The .mean() does both the Σ and the 1/n.
Key takeaways
- Σ means "add up": below is where the counter starts, above is where it stops, after is what to add.
- Read Σᵢ₌₁ⁿ xᵢ as "the sum of x i for i from 1 to n"; it's a loop with a running total.
- Constants come out of sums, and sums split over +; but Σxᵢ² ≠ (Σxᵢ)².
- A double sum ΣᵢΣⱼ adds every cell of a table.
- In NumPy, write the term for the whole array, then call
.sum()(or.mean()for (1/n)Σ).
Frequently asked questions
What does the Σ symbol mean in maths?
It's the Greek capital letter sigma, meaning "sum": add up the expression after it for every value of the counter between the lower and upper limits.
How do you read Σ from i = 1 to n of xᵢ?
"The sum of x i, for i from 1 to n." It means x₁ + x₂ + … + xₙ: add up all n values.
How do you write summation in Python?
Use sum() on a list or generator, such as sum(i ** 2 for i in range(1, 5)), or .sum() on a NumPy array or pandas column.
What to learn next
- Meet Σ's multiplying cousin in product notation (Π) explained.
- Revisit maths notation and symbols.