## 1.7 Summation

The sum of $$n$$ numbers $$x_1, x_2, ..., x_n$$ is represented by $$\sum_{i=1}^n {x_i} = x_1 + x_2 + \dotsb + x_n$$, and reads ‘sum of x $$i$$ from one to n’.

Example 1.6 (Number of steps) Suppose the variable $$X$$: ‘number of steps to the nearest trash can’ was observed in the city of Porto Alegre on $$n = 6$$ occasions, as shown in the table below.

$$x_{1}$$ $$x_{2}$$ $$x_{3}$$ $$x_{4}$$ $$x_{5}$$ $$x_{6}$$
186 402 191 20 7 124

This table indicates that on the first occasion, 186 steps were walked to locate a trash can (represented by $$x_1=186$$), on the second occasion, 402 steps were walked (represented by $$x_2=402$$), and so on. To calculate the total number of steps walked, you can do

$$$\sum_{i=1}^6 {x_i} = x_1 + x_2 + \dotsb + x_6 = 186+402+191+20+7+124 = 930 \tag{1.1}$$$

186+402+191+20+7+124            # R and RStudio are calculators
## [1] 930
x <- c(186,402,191,20,7,124)    # We can create a vector and assign it to x
sum(x)                          # Using the 'sum' function, presented in Equation (1.1)
## [1] 930
sum(x^2)                        # Sum of squares, represented by Equation (1.2)
## [1] 248506

The Greek letter $$\sum$$ is the capital sigma, as per Section 1.9.1. In many cases the summation symbology is simplified, using $$\sum$$, $$\sum_{x}$$ or $$\sum_{i}$$. Below are some more advanced examples of more sophisticated use of summation, which can be omitted on a first read.

$$$\sum_{i=1}^n x_{i}^2 = x_{1}^2 + x_{2}^2 + \ldots + x_{n}^2 \tag{1.2}$$$