# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/mathematics/statistics-foundations/variance-standard-deviation-data-single
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/mathematics/statistics-foundations/variance-standard-deviation-data-single/en.mdx

Learn how to calculate variance and standard deviation for ungrouped data with formulas and examples.

---

## Measuring Spread with Variance and Standard Deviation

Two common ways to measure how spread out our data is are **Variance** and **Standard Deviation**.

These two measures tell us how far, on average, each data point deviates from the group's **mean** (average).

- If the **Variance** or **Standard Deviation** value is **small**, it means the data points in the group tend to be **uniform** or **similar**, clustering **close** to the mean value.
- If the value is **large**, it means the data points are more **varied** or **diverse**, spreading **further away** from the mean value.

## Formulas for Variance and Standard Deviation

1.  **Variance ($$\sigma^2$$)**

    Variance is the average of the squared differences of each data point from the mean. Confused? Simply put: calculate the difference between each data point and the mean, square the result, then average those squared differences.

    The formula is:

    
    
    ```math
    \sigma^2 = \frac{\sum_{i=1}^{n}(x_i - \bar{x})^2}{n}
    ```

    Where:

    - $$\sigma^2$$ = Variance
    - $$x_i$$ = Value of the i-th data point
    - $$\bar{x}$$ = Mean (average) of the data
    - $$n$$ = Number of data points
    - $$\sum$$ = Sum all the calculated results

2.  **Standard Deviation ($$\sigma$$)**

    Standard deviation is more commonly used because its unit is the same as the original data unit (variance has squared units). It's simple: just take the square root of the variance.

    The formula is:

    
    
    ```math
    \sigma = \sqrt{\sigma^2} = \sqrt{\frac{\sum_{i=1}^{n}(x_i - \bar{x})^2}{n}}
    ```

Visible text: 1. **Variance ()**

 Variance is the average of the squared differences of each data point from the mean. Confused? Simply put: calculate the difference between each data point and the mean, square the result, then average those squared differences.

 The formula is:

 
 

 Where:

 - = Variance
 - = Value of the i-th data point
 - = Mean (average) of the data
 - = Number of data points
 - = Sum all the calculated results

2. **Standard Deviation ()**

 Standard deviation is more commonly used because its unit is the same as the original data unit (variance has squared units). It's simple: just take the square root of the variance.

 The formula is:

## Comparing Variance in Two Age Groups

Let's use an example of two groups of age data to see how variance and standard deviation work. These groups are interesting because they have the **same mean ($$\bar{x}$$), which is $$16$$**, but their data spreads are different.

Visible text: Let's use an example of two groups of age data to see how variance and standard deviation work. These groups are interesting because they have the **same mean (), which is **, but their data spreads are different.

- **Group One ($$n=12$$):** $$13, 14, 15, 15, 16, 16, 17, 17, 17, 17, 17, 18$$
- **Group Two ($$n=12$$):** $$1, 3, 4, 5, 7, 8, 12, 27, 28, 29, 32, 36$$

Visible text: - **Group One ():** 
- **Group Two ():**

Now, let's calculate the Variance and Standard Deviation for each group.

### Calculation for First Group

We calculate $$(x_i - \bar{x})^2$$ for each data point in Group $$1$$ ($$\bar{x}=16$$):

Visible text: We calculate for each data point in Group ():

- $$(13-16)^2 = (-3)^2 = 9$$
- $$(14-16)^2 = (-2)^2 = 4$$
- $$(15-16)^2 = (-1)^2 = 1$$ ($$2 \text{ data points}$$)
- $$(16-16)^2 = (0)^2 = 0$$ ($$2 \text{ data points}$$)
- $$(17-16)^2 = (1)^2 = 1$$ ($$5 \text{ data points}$$)
- $$(18-16)^2 = (2)^2 = 4$$

Visible text: - 
- 
- ()
- ()
- ()
-

Now sum all these squared results ($$\sum(x_i - \bar{x})^2$$):

Visible text: Now sum all these squared results ():

```math
9 + 4 + (1 \times 2) + (0 \times 2) + (1 \times 5) + 4 = 9 + 4 + 2 + 0 + 5 + 4 = 24
```

Calculate the Variance:

```math
\sigma^2_{\text{Group 1}} = \frac{\sum(x_i - \bar{x})^2}{n} = \frac{24}{12} = 2
```

Calculate the Standard Deviation:

```math
\sigma_{\text{Group 1}} = \sqrt{2} \approx 1.41
```

### Calculation for Second Group

We calculate $$(x_i - \bar{x})^2$$ for each data point in Group $$2$$ ($$\bar{x}=16$$):

Visible text: We calculate for each data point in Group ():

- $$(1-16)^2 = (-15)^2 = 225$$
- $$(3-16)^2 = (-13)^2 = 169$$
- $$(4-16)^2 = (-12)^2 = 144$$
- $$(5-16)^2 = (-11)^2 = 121$$
- $$(7-16)^2 = (-9)^2 = 81$$
- $$(8-16)^2 = (-8)^2 = 64$$
- $$(12-16)^2 = (-4)^2 = 16$$
- $$(27-16)^2 = (11)^2 = 121$$
- $$(28-16)^2 = (12)^2 = 144$$
- $$(29-16)^2 = (13)^2 = 169$$
- $$(32-16)^2 = (16)^2 = 256$$
- $$(36-16)^2 = (20)^2 = 400$$

Visible text: - 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-

Sum all these squared results ($$\sum(x_i - \bar{x})^2$$):

Visible text: Sum all these squared results ():

```math
225 + 169 + 144 + 121 + 81 + 64 + 16 + 121 + 144 + 169 + 256 + 400 = 1910
```

Calculate the Variance:

```math
\sigma^2_{\text{Group 2}} = \frac{\sum(x_i - \bar{x})^2}{n} = \frac{1910}{12} \approx 159.17
```

Calculate the Standard Deviation:

```math
\sigma_{\text{Group 2}} = \sqrt{159.17} \approx 12.62
```

### Interpreting the Results

- Variance of Group $$1$$ ($$\sigma^2 = 2$$) is **much smaller** than the Variance of Group $$2$$ ($$\sigma^2 \approx 159.17$$).
- Standard Deviation of Group $$1$$ ($$\sigma \approx 1.41$$) is also **much smaller** than the Standard Deviation of Group $$2$$ ($$\sigma \approx 12.62$$).

Visible text: - Variance of Group () is **much smaller** than the Variance of Group ().
- Standard Deviation of Group () is also **much smaller** than the Standard Deviation of Group ().

These results show that the age data in **Group $$1$$ is very clustered and uniform** around the mean of $$16$$, whereas the age data in **Group $$2$$ is widely spread out** far from the mean of $$16$$.

Visible text: These results show that the age data in **Group is very clustered and uniform** around the mean of , whereas the age data in **Group is widely spread out** far from the mean of .

## Alternative Formula for Variance

There's another way to calculate variance that is sometimes easier with a calculator or computer, especially for large datasets. The formula is:

```math
\sigma^2 = \frac{\sum x_i^2}{n} - \left( \frac{\sum x_i}{n} \right)^2
```

This formula says: "Calculate the square of each data point and sum them up ($$\sum x_i^2$$), divide by $$n$$. Then subtract the square of the mean ($$(\bar{x})^2 = (\frac{\sum x_i}{n})^2$$)".

Visible text: This formula says: "Calculate the square of each data point and sum them up (), divide by . Then subtract the square of the mean ()".

Let's recalculate the variance for Group $$1$$ using this formula:

Visible text: Let's recalculate the variance for Group using this formula:

1.  Calculate $$\sum x_i^2$$ for Group $$1$$:

    <MathContainer>
      
    
    ```math
    13^2 + 14^2 + 15^2 + 15^2 + 16^2 + 16^2 + 17^2 + 17^2 + 17^2 + 17^2 + 17^2 + 18^2
    ```

      
    
    ```math
    = 169 + 196 + 225 + 225 + 256 + 256 + 289 + 289 + 289 + 289 + 289 + 324 = 3096
    ```

    </MathContainer>

2.  Calculate $$\sum x_i$$ for Group $$1$$:

    <MathContainer>
      
    
    ```math
    13 + 14 + 15 + 15 + 16 + 16 + 17 + 17 + 17 + 17 + 17 + 18
    ```

      
    
    ```math
    = 192
    ```

    </MathContainer>

    We also know $$n=12$$.

3.  Plug into the alternative formula:

    <MathContainer>
      
    
    ```math
    \sigma^2 = \frac{3096}{12} - \left( \frac{192}{12} \right)^2
    ```

      
    
    ```math
    \sigma^2 = 258 - (16)^2
    ```

      
    
    ```math
    \sigma^2 = 258 - 256 = 2
    ```

    </MathContainer>

Visible text: 1. Calculate for Group :

 <MathContainer>
 
 

 
 

 </MathContainer>

2. Calculate for Group :

 <MathContainer>
 
 

 
 

 </MathContainer>

 We also know .

3. Plug into the alternative formula:

 <MathContainer>
 
 

 
 

 
 

 </MathContainer>

The result is **exactly the same** as the first method! ($$\sigma^2 = 2$$).

Visible text: The result is **exactly the same** as the first method! ().