How to Calculate Variance: 15 Steps (With Pictures)

Table of contents:

How to Calculate Variance: 15 Steps (With Pictures)
How to Calculate Variance: 15 Steps (With Pictures)
Anonim

Variance is a measure of how sparse a data set is. It is useful when creating statistical models because low variance can be a sign that you are overfitting your data. Calculating the variance can be tricky, but once you learn the formula, you only need to enter the correct numbers to find the answer.

Steps

Method 1 of 2: Calculate the variance of a sample

Calculate_Variance_Step_1
Calculate_Variance_Step_1

Step 1. Make a note of the sample of the data set

In most cases, statisticians only have access to a sample or a subset of the population that they are going to analyze. For example, instead of analyzing the population "cost of all cars in Germany", a statistician would find the cost of a random sample of a few thousand cars. You could then use that sample to get a rough estimate of the cost of the cars in Germany, although it may not match the exact value.

  • Example:

    Analyzing the number of muffins that are sold every day in a cafeteria, you take a sample of six random days and obtain the following results: 17, 15, 23, 7, 9, 13. This is a sample, not the population, since you do not have the data for each and every day the cafeteria has been open.

  • If you have all the data points for a population, continue with the next method.
Calculate_Variance_Step_2
Calculate_Variance_Step_2

Step 2. Record the formula for the variance of a sample

The variance of a data set tells you how spread out the data points are. The closer to zero the variance is, the closer the data points are to each other. When working with sample data sets, use the following formula to calculate the variance:

  • s2 { displaystyle s ^ {2}}

    = ∑[(xi{displaystyle x_{i}}

    - x̅)2{displaystyle ^{2}}

    ]/(n - 1)

  • s2{displaystyle s^{2}}
  • es la varianza. La varianza siempre se mide en unidades elevadas al cuadrado.

  • xi{displaystyle x_{i}}
  • represents a term from your data set. </li>

    y luego sumarlos a todos.

  • x̅ es la media de la muestra.
  • n es la cantidad de puntos de datos.
Calculate_Variance_Step_3
Calculate_Variance_Step_3

Step 3. Find the mean of the sample

The symbol x̅ or "x bar" refers to the sample mean. Calculate it as you would any mean: add all the data points, then divide by the number of data points.

  • For example: first add all the data points: 17 + 15 + 23 + 7 + 9 + 13 = 84

    Next, divide the 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 is clustered close to the mean, then the variance will be low. If they are scattered far from the mean, the variance will be high.
Calculate Variance Step 4
Calculate Variance Step 4

Step 4. Subtract the mean from each data point

Now it's time to calculate xi { displaystyle x_ {i}}

- x̅, donde xi{displaystyle x_{i}}

es cada número del conjunto de datos. Cada respuesta te indicará la desviación con respecto de la media o, en lenguaje coloquial, qué tan lejos de la media está cada número..

  • Ejemplo:

    x1{displaystyle x_{1}}

    - x̅ = 17 - 14 = 3

    x2{displaystyle x_{2}}

    - x̅ = 15 - 14 = 1

    x3{displaystyle x_{3}}

    - x̅ = 23 - 14 = 9

    x4{displaystyle x_{4}}

    - x̅ = 7 - 14 = -7

    x5{displaystyle x_{5}}

    - x̅ = 9 - 14 = -5

    x6{displaystyle x_{6}}

    - x̅ = 13 - 14 = -1

  • Es fácil revisar tu trabajo, ya que la suma de las respuestas debe ser igual a cero. Esto se debe justamente a la definición de la media, ya que las respuestas negativas (distancia de los números pequeños respecto de la media) cancelan exactamente las respuestas positivas (distancia de los números más grandes respecto de la media).
Calculate Variance Step 5
Calculate Variance Step 5

Step 5. Square each result

As explained above, the current list of deviations (xi { displaystyle x_ {i}}

- x̅) add up to zero. This means that the" desviación="" promedio"="" siempre="" será="" igual="" a="" cero.="" por="" lo="" tanto,="" esto="" no="" te="" dice="" demasiado="" acerca="" de="" qué="" tan="" dispersos="" están="" los="" datos.="" para="" resolver="" este="" problema,="" debes="" elevar="" al="" cuadrado="" cada="" desviación.="" al="" hacerlo,="" todos="" los="" números="" se="" convertirán="" en="" positivos,="" por="" lo="" tanto,="" los="" valores="" positivos="" y="" negativos="" dejarán="" de="" cancelarse="" y="" sumar=" />

  • Example:

    (x1 { displaystyle x_ {1}}

    - x̅)2=32=9{displaystyle ^{2}=3^{2}=9}

    (x2{displaystyle (x_{2}}

    - x̅)2=12=1{displaystyle ^{2}=1^{2}=1}

    92 = 81

    (-7)2 = 49

    (-5)2 = 25

    (-1)2 = 1

  • Ahora tienes el valor (xi{displaystyle x_{i}}
  • - x̅)2{displaystyle ^{2}}

    para cada punto de datos de tu muestra.

Calculate Variance Step 6
Calculate Variance Step 6

Step 6. Find the sum of the squared values

Now it is time to calculate the total numerator of the formula ∑ [(xi { displaystyle x_ {i}}

- x̅)2{displaystyle ^{2}}

]. La letra sigma mayúscula, ∑, te indica que debes sumar el valor del siguiente término para cada valor de xi{displaystyle x_{i}}

. Ya calculaste (xi{displaystyle x_{i}}

- x̅)2{displaystyle ^{2}}

para cada valor de xi{displaystyle x_{i}}

en la muestra. Así que todo lo que tienes que hacer ahora, es sumar los resultados.

  • Ejemplo:

    9 + 1 + 81 + 49 + 25 + 1 = 166.

Calculate Variance Step 7
Calculate Variance Step 7

Step 7. Divide by n − 1 { displaystyle n-1}

, donde n{displaystyle n}

es la cantidad de puntos de datos.

Hace mucho tiempo, los estadísticos dividían la varianza de la muestra por n{displaystyle n}

. Esto te da el valor promedio de la desviación al cuadrado, que coincide perfectamente con la varianza de la muestra. Pero recuerda que la muestra es solo una estimación de una población más grande. Si tomas otra muestra aleatoria y haces el mismo cálculo, obtendrás un resultado diferente. Por este motivo, al dividir por n−1{displaystyle n-1}

en vez de por n{displaystyle n}

obtendrás una mejor estimación de la varianza de una población más grande y eso es justamente lo que estás buscando. Esta corrección es tan común que se ha convertido en la definición aceptada de la varianza de una muestra.

  • Ejemplo:

    en la muestra hay seis puntos de datos, por lo tanto:

    Varianza de la muestra = s2=1666−1={displaystyle s^{2}={frac {166}{6-1}}=}

    33, 2

Calculate_Variance_Step_8
Calculate_Variance_Step_8

Step 8. Learn to distinguish variance from standard deviation

Note that since there is an exponent in the formula, the variance is measured in units squared of the original data. This may make it difficult to understand intuitively. Instead, the standard deviation is often used. However, your effort was not in vain, since the standard deviation is nothing other than the square root of the variance. That is why the variance of a sample is expressed as s2 { displaystyle s ^ {2}}

y la desviación estándar de una muestra como s{displaystyle s}

Por ejemplo, la desviación estándar de la muestra anterior es = s = √33, 2 = 5, 76

Método 2 de 2: Calcular la varianza de una población

Calculate_Variance_Step_9 EN
Calculate_Variance_Step_9 EN

Step 1. Start with a population data set

The term "population" refers to the total data of the relevant observations. For example, if you are analyzing the age of residents of the state of Texas, your population should include the age of each of the residents of Texas. Normally, for a data set as large as that, you would create a spreadsheet. However, here is a smaller set of data as an example:

  • Example:

    There are exactly 6 tanks in an aquarium room. The six tanks contain the following number of fish:

    x1 = 5 { displaystyle x_ {1} = 5}

    x2=5{displaystyle x_{2}=5}

    x3=8{displaystyle x_{3}=8}

    x4=12{displaystyle x_{4}=12}

    x5=15{displaystyle x_{5}=15}

    x6=18{displaystyle x_{6}=18}

Calculate_Variance_Step_10 EN
Calculate_Variance_Step_10 EN

Step 2. Write down the formula for the variance of the population

Since the population contains all the data you need, this formula will give you the exact value of the variance of the population. In order to distinguish it from the variance of a sample (which is only an approximate value), statisticians use other variables:

  • σ2 { displaystyle ^ {2}}

    = (∑(xi{displaystyle x_{i}}

    - μ)2{displaystyle ^{2}}

    )/

  • σ2{displaystyle ^{2}}
  • = varianza de la población. Es la letra sigma minúscula, elevada al cuadrado. La varianza se mide en unidades al cuadrado.

  • xi{displaystyle x_{i}}
  • representa un término de tu conjunto de datos.

  • Los términos dentro de ∑ se calcularán para cada valor de xi{displaystyle x_{i}}
  • , y luego se sumarán.

  • μ es la media de la población.
  • n es la cantidad de puntos de datos de la población.
Calculate_Variance_Step_11 EN
Calculate_Variance_Step_11 EN

Step 3. Find the mean of the population

When you analyze a population, the symbol μ ("mu") represents the arithmetic mean. To find the mean, add all the data points and then divide the result by the number of data points.

  • You can think of the mean as the "average", but be careful, as that word has many definitions in math.
  • Example:

    mean = μ = 5 + 5 + 8 + 12 + 15 + 186 { displaystyle { frac {5 + 5 + 8 + 12 + 15 + 18} {6}}}

    = 10, 5

Calculate Variance Step 12
Calculate Variance Step 12

Step 4. Subtract the mean from each data point

Data points close to the mean will have a difference closer to zero. Repeat the subtraction for each data point and you will begin to get a rough notion of how spread out the data is.

  • Example:

    x1 { displaystyle x_ {1}}

    - μ = 5 - 10, 5 = -5, 5

    x2{displaystyle x_{2}}

    - μ = 5 - 10, 5 = -5, 5

    x3{displaystyle x_{3}}

    - μ = 8 - 10, 5 = -2, 5

    x4{displaystyle x_{4}}

    - μ = 12 - 10, 5 = 1, 5

    x5{displaystyle x_{5}}

    - μ = 15 - 10, 5 = 4, 5

    x6{displaystyle x_{6}}

    - μ = 18 - 10, 5 = 7, 5

Calculate Variance Step 13
Calculate Variance Step 13

Step 5. Square all the answers

Now some of the numbers from the previous step will be negative while others will be positive. If you draw your data on a number line, these two categories will represent the numbers that are to the left of the mean and those that are to the right of the mean. These values are not very helpful in calculating the variance, since the two groups would cancel each other out. Square each of the numbers to transform them into positive values.

  • Example:

    (xi { displaystyle x_ {i}}

    - μ)2{displaystyle ^{2}}

    para cada valor de i de 1 a 6:

    (-5, 5)2{displaystyle ^{2}}

    = 30, 25

    (-5, 5)2{displaystyle ^{2}}

    = 30, 25

    (-2, 5)2{displaystyle ^{2}}

    = 6, 25

    (1, 5)2{displaystyle ^{2}}

    = 2, 25

    (4, 5)2{displaystyle ^{2}}

    = 20, 25

    (7, 5)2{displaystyle ^{2}}

    = 56, 25

Calculate Variance Step 14
Calculate Variance Step 14

Step 6. Find the mean of your results

Now you have a value for each data point, related (indirectly) to the spread that that data point has from the mean. Find the mean of these values by adding them and then dividing the sum by the number of values.

  • Example:

    Population variance = 30, 25 + 30, 25 + 6, 25 + 2, 25 + 20, 25 + 56, 256 = 145, 56 = { displaystyle { frac {30, 25 + 30, 25 + 6, 25 + 2, 25 + 20, 25 + 56, 25} {6}} = { frac {145, 5} {6}} =}

    24, 25

Calculate Variance Step 15
Calculate Variance Step 15

Step 7. Relate this value back to the formula

If you're not sure how this value matches the formula you applied at the beginning of this method, try writing the entire problem by hand:

  • After finding the difference between the mean and squaring, you will get the value (x1 { displaystyle x_ {1}}

    - μ)2{displaystyle ^{2}}

    , (x2{displaystyle x_{2}}

    - μ)2{displaystyle ^{2}}

    , y así sucesivamente hasta (xn{displaystyle x_{n}}

    - μ)2{displaystyle ^{2}}

    , donde xn{displaystyle x_{n}}

    es el último punto de datos del conjunto.

  • para encontrar la media de estos valores, debes sumarlos a todos y dividirlos por n{displaystyle n}
  • : ((x1{displaystyle x_{1}}

    - μ)2{displaystyle ^{2}}

    + (x2{displaystyle x_{2}}

    - μ)2{displaystyle ^{2}}

    + … + (xn{displaystyle x_{n}}

    - μ)2{displaystyle ^{2}}

    ) / n

  • después de rescribir el numerador en notación sigma, obtendrás (∑(xi{displaystyle x_{i}}
  • - μ)2{displaystyle ^{2}}

    )/ , que es la fórmula de la varianza.

consejos

  • debido a que es difícil interpretar la varianza, este valor generalmente se calcula como punto de partida para el cálculo de la desviación estándar.
  • la utilización de n−1{displaystyle n-1}
  • en lugar de n{displaystyle n}

    en el denominador al analizar muestras, es una técnica conocida como corrección de bessel. la muestra es solo un valor estimativo de la población completa y la media de la muestra se encuentra sesgada para ajustar esa estimación. esta corrección sirve para eliminar ese sesgo. esto tiene que ver con el hecho de que, una vez que hayas listado los n−1{displaystyle n-1}

    puntos de datos, el n-ésimo punto final ya tendrá una restricción, dado que solamente algunos valores resultarán en la media de la muestra (x̅) utilizada en la fórmula de la varianza.

Popular by topic