# Variance
Used to calculate how the data is spread around the population [[Mean]] Greek (mu). If calculating not estimating a population variance then the formula is:
$population\ variance = \frac{\sum(x-\mu)^2}{n}$
we square the differences to ensure the value is positive and $n$ represents the population, to allow for skewing in a sample we do $n-1$ Once the variance has been calculated it is still squared so we need to take the square root of the entire things
$population\ variance = \frac{\sum(x-\mu)^2}{n}$
If we were performing these calculations for a sample of a population (the most likely case) then the formula to use would look like this
$sample\ variance = \frac{\sum(x-\bar x)^2}{n-1}$
the square root of the calculated result of the formula is the [[Standard Deviation]] of the sample values
The variance is sensitive to outliers but it is a very useful value to have.
## Documentation
<center>
<iframe width="560" height="315" src="https://www.youtube.com/embed/SzZ6GpcfoQY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</center>
## Code
```r
# This function uses n-1 by default for a population sample
var(x, y = NULL, na.rm = FALSE, use)
```