Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AWS AI GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

Statistic Variability (Spread)

Descriptive Statistics is broken down into Tendency and Variability.

Variability uses these measures:

  • Min and Max
  • Variance
  • Deviation
  • Distribution
  • Skewness
  • Kurtosis

The Variance

In statistics, the Variance is the average of the squared differences from the Mean Value.

In other words, the variance describes how far a set of numbers is Spread Out from the mean (average) value.

Mean value is described in the previous chapter.

This table contains 11 values:

7889991011141415

Calculate the Variance:

// Calculate the Mean (m)
let m = (7+8+8+9+9+9+10+11+14+14+15)/11;

// Calculate the Sum of Squares (ss)
let ss = (7-m)**2 + (8-m)**2 + (8-m)**2 + (9-m)**2 + (9-m)**2 + (9-m)**2 + (9-m)**2 + (10-m)**2 + (11-m)**2 + (14-m)**2 + (15-m)**2;

// Calculate the Variance
let variance = ss / 11;

Try it Yourself »

Or use a math library like math.js:

const values = [7,8,8,9,9,9,10,11,14,14,15];
let variance = math.variance(values, "uncorrected");

Try it Yourself »



Standard Deviation

Standard Deviation is a measure of how spread out numbers are.

The symbol is σ (Greek letter sigma).

The formula is the variance (the square root of the variance).

The Standard Deviation is (in JavaScript):

// Calculate the Mean (m)
let m = (7+8+8+9+9+9+10+11+14+15)/11;

// Calculate the Sum of Squares (ss)
let ss = (7-m)**2 + (8-m)**2 + (8-m)**2 + (9-m)**2 + (9-m)**2 + (9-m)**2 + (9-m)**2 + (10-m)**2 + (11-m)**2 + (14-m)**2 + (15-m)**2;

// Calculate the Variance
let variance = ss / 11;

// Calculate the Standard Deviation
let std = Math.sqrt(variance);

Try it Yourself »

Deviation is a measure of Distance.

How far (on average), all values are from the Mean (the Middle).

Or if you use a math library like math.js:

const values = [7,8,8,9,9,9,9,10,11,14,15];
let std = math.std(values, "uncorrected");

Try it Yourself »


W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2023 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.