PDF download Download Article PDF download Download Article

What is variance? Variance is a measure of how spread out a data set is, and we calculate it by finding the average of each data point's squared difference from the mean. [1] It's useful when creating statistical models since low variance can be a sign that you are over-fitting your data. Once you get the hang of the formula, you'll just have to plug in the right numbers to find your answer. Read on for a complete step-by-step tutorial that'll teach you how to calculate both sample variance and population variance.

Method 1
Method 1 of 2:

Calculating Sample Variance

PDF download Download Article
  1. In most cases, statisticians only have access to a sample, or a subset of the population they're studying. For example, instead of analyzing the population "cost of every car in Germany," a statistician could find the cost of a random sample of a few thousand cars. He can use this sample to get a good estimate of German car costs, but it will likely not match the actual numbers exactly. [2]
    • Example: Analyzing the number of muffins sold each day at a cafeteria, you sample six days at random and get these results: 38, 37, 36, 28, 18, 14, 12, 11, 10.7, 9.9. This is a sample, not a population, since you don't have data on every single day the cafeteria was open.
    • If you have every data point in a population, skip down to the method below instead .
  2. The variance of a data set tells you how spread out the data points are. The closer the variance is to zero, the more closely the data points are clustered together. When working with sample data sets, use the following formula to calculate variance: [3]
    • = ∑[( - xÌ…) ] / (n - 1)
    • is the variance. Variance is always measured in squared units.
    • represents a term in your data set.
    • ∑, meaning "sum," tells you to calculate the following terms for each value of , then add them together.
    • xÌ… is the mean of the sample.
    • n is the number of data points.
    Advertisement
  3. Calculate the mean of the sample. The symbol xÌ… or "x-bar" refers to the mean of a sample. [4] Calculate this as you would any mean: add all the data points together, then divide by the number of data points. [5]
    • Example: First, add your data points together: 17 + 15 + 23 + 7 + 9 + 13 = 84
      Next, divide your answer by the number of data points, in this case six: 84 ÷ 6 = 14.
      Sample mean = xÌ… = 14 .
    • You can think of the mean as the "center-point" of the data. If the data clusters around the mean, variance is low. If it is spread out far from the mean, variance is high. [6]
  4. Now it's time to calculate - xÌ…, where is each number in your data set. Each answer tells you that number's deviation from the mean, or in plain language, how far away it is from the mean. [7]
    • Example:
      - xÌ… = 17 - 14 = 3
      - xÌ… = 15 - 14 = 1
      - xÌ… = 23 - 14 = 9
      - xÌ… = 7 - 14 = -7
      - xÌ… = 9 - 14 = -5
      - xÌ… = 13 - 14 = -1
    • It's easy to check your work, as your answers should add up to zero. This is due to the definition of mean, since the negative answers (distance from mean to smaller numbers) exactly cancel out the positive answers (distance from mean to larger numbers).
  5. Square each result. As noted above, your current list of deviations ( - xÌ…) sum up to zero. This means the "average deviation" will always be zero as well, so that doesn't tell use anything about how spread out the data is. To solve this problem, find the square of each deviation. [8] This will make them all positive numbers, so the negative and positive values no longer cancel out to zero. [9]
    • Example:
      ( - xÌ…)
      - xÌ…)
      9 2 = 81
      (-7) 2 = 49
      (-5) 2 = 25
      (-1) 2 = 1
    • You now have the value ( - xÌ…) for each data point in your sample.
  6. Now it's time to calculate the entire numerator of the formula: ∑[( - xÌ…) ]. The upper-case sigma, ∑, tells you to sum the value of the following term for each value of . You've already calculated ( - xÌ…) for each value of in your sample, so all you need to do is add the results of all of the squared deviations together. [10] [11]
    • Example: 9 + 1 + 81 + 49 + 25 + 1 = 166 .
  7. A long time ago, statisticians just divided by n when calculating the variance of the sample. This gives you the average value of the squared deviation, which is a perfect match for the variance of that sample. But remember, a sample is just an estimate of a larger population. If you took another random sample and made the same calculation, you would get a different result. As it turns out, dividing by n - 1 instead of n gives you a better estimate of variance of the larger population, which is what you're really interested in. This correction is so common that it is now the accepted definition of a sample's variance. [12]
    • Example: There are six data points in the sample, so n = 6.
      Variance of the sample = 33.2
  8. Understand variance and standard deviation . Note that, since there was an exponent in the formula, variance is measured in the squared unit of the original data. This can make it difficult to understand intuitively. Instead, it's often useful to use the standard deviation. You didn't waste your effort, though, as the standard deviation is defined as the square root of the variance. This is why the variance of a sample is written , and the standard deviation of a sample is .
    • For example, the standard deviation of the sample above = s = √33.2 = 5.76.
  9. Advertisement
Method 2
Method 2 of 2:

Calculating Population Variance

PDF download Download Article
  1. The term "population" refers to the total set of relevant observations. For example, if you're studying the age of Texas residents, your population would include the age of every single Texas resident. You would normally create a spreadsheet for a large data set like that, but here's a smaller example data set: [13]
    • Example: There are exactly six fish tanks in a room of the aquarium. The six tanks contain the following numbers of fish:





  2. Since a population contains all the data you need, this formula gives you the exact variance of the population. In order to distinguish it from sample variance (which is only an estimate), statisticians use different variables: [14]
    • σ = (∑( - μ) ) / n
    • σ = population variance. This is a lower-case sigma, squared. Variance is measured in squared units.
    • represents a term in your data set.
    • The terms inside ∑ will be calculated for each value of , then summed.
    • μ is the population mean
    • n is the number of data points in the population
  3. When analyzing a population, the symbol μ ("mu") represents the arithmetic mean. To find the mean, add all the data points together, then divide by the number of data points. [15]
    • You can think of the mean as the "average," but be careful, as that word has multiple definitions in mathematics.
    • Example: mean = μ = = 10.5
  4. Data points close to the mean will result in a difference closer to zero. Repeat the subtraction problem for each data point, and you might start to get a sense of how spread out the data is. [16]
    • Example:
      - μ = 5 - 10.5 = -5.5
      - μ = 5 - 10.5 = -5.5
      - μ = 8 - 10.5 = -2.5
      - μ = 12 - 10.5 = 1.5
      - μ = 15 - 10.5 = 4.5
      - μ = 18 - 10.5 = 7.5
  5. Right now, some of your numbers from the last step will be negative, and some will be positive. If you picture your data on a number line, these two categories represent numbers to the left of the mean, and numbers to the right of the mean. This is no good for calculating variance, since these two groups will cancel each other out. Square each number so they are all positive instead. [17]
    • Example:
      ( - μ) for each value of i from 1 to 6:
      (-5.5) = 30.25
      (-5.5) = 30.25
      (-2.5) = 6.25
      (1.5) = 2.25
      (4.5) = 20.25
      (7.5) = 56.25
  6. Now you have a value for each data point, related (indirectly) to how far that data point is from the mean. Take the mean of these values by adding them all together, then dividing by the number of values. [18]
    • Example:
      Variance of the population = 24.25
  7. If you're not sure how this matches the formula at the beginning of this method, try writing out the whole problem in longhand:
    • After finding the difference from the mean and squaring, you have the value ( - μ) , ( - μ) , and so on up to ( - μ) , where is the last data point in the set.
    • To find the mean of these values, you sum them up and divide by n: ( ( - μ) + ( - μ) + ... + ( - μ) ) / n
    • After rewriting the numerator in sigma notation, you have (∑( - μ) ) / n , the formula for variance.
  8. Advertisement

Help Calculating Variance

Expert Q&A

Search
Add New Question
  • Question
    What are deviations?
    Mario Banuelos, PhD
    Associate Professor of Mathematics
    Mario Banuelos is an Associate Professor of Mathematics at California State University, Fresno. With over eight years of teaching experience, Mario specializes in mathematical biology, optimization, statistical models for genome evolution, and data science. Mario holds a BA in Mathematics from California State University, Fresno, and a Ph.D. in Applied Mathematics from the University of California, Merced. Mario has taught at both the high school and collegiate levels.
    Associate Professor of Mathematics
    Expert Answer
    A deviation is the distance of an observation or a data point from the mean, or the center of all the data points. it gives you a sense of how spread apart the data is from the mean.
  • Question
    What is the easiest way to find variance?
    Mario Banuelos, PhD
    Associate Professor of Mathematics
    Mario Banuelos is an Associate Professor of Mathematics at California State University, Fresno. With over eight years of teaching experience, Mario specializes in mathematical biology, optimization, statistical models for genome evolution, and data science. Mario holds a BA in Mathematics from California State University, Fresno, and a Ph.D. in Applied Mathematics from the University of California, Merced. Mario has taught at both the high school and collegiate levels.
    Associate Professor of Mathematics
    Expert Answer
    First, calculate the mean or average of all of the data points. Then, calculate the difference between each data point and that mean. Square each of those differences, add them all up, then divide them by n (the total number of data points) minus 1.
  • Question
    How do I calculate the variance of four numbers?
    Community Answer
    Follow these steps: Work out the mean (the simple average of the numbers.) Then, for each number, subtract the mean and square the result (the squared difference). Finally, work out the average of those squared differences.
See more answers
Ask a Question
      Advertisement

      Tips

      • Using "n-1" instead of "n" in the denominator when analyzing samples is a technique called Bessel's correction. The sample is only an estimate of the full population, and the mean of the sample is biased to fit that estimate. This correction removes this bias. This is related to the fact that, once you've listed n - 1 data points, the final n th point is already constrained, since only certain values will result in the sample mean (xÌ…) used in the variance formula. [19]
      • Since it is difficult to interpret the variance, this value is usually calculated as a starting point for calculating the standard deviation.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Article Summary X

      To calculate the variance of a sample, or how spread out the sample data is across the distribution, first add all of the data points together and divide by the number of data points to find the mean. For example, if your data points are 3, 4, 5, and 6, you would add 3 + 4 + 5 + 6 and get 18. Then, you would divide 18 by the total number of data points, which is 4, and get 4.5. Therefore, the mean of the data set is 4.5. Next, subtract the mean from each data point in the sample. In this example, you would subtract the mean, or 4.5, from 3, then 4, then 5, and finally 6 and end up with -1.5, -0.5, 0.5, and 1.5. Now, square each of these results by multiplying each result by itself. If you square -1.5, -0.5, 0.5, and 1.5, you would get 2.25, 0.25, 0.25, and 2.25. Then, add up all of the squared values. Here, you would add 2.25 + 0.25 + 0.25 + 2.25 and get 5. Finally, divide the sum by n - 1, where n is the total number of data points. In the example there are 4 data points, so you would divide the sum, which is 5, by 4 - 1, or 3, and get 1.66. Therefore, the variance of the sample is 1.66. To learn how to calculate the variance of a population, scroll down!

      Did this summary help you?
      Thanks to all authors for creating a page that has been read 3,099,057 times.

      Reader Success Stories

      • Andrew Raad

        Jul 17, 2016

        "I am currently solving a non-perfect hedge problem between grapefruit and orange juice where I need to calculate ..." more
      Share your story

      Did this article help you?

      Advertisement