StatsCalculators.com

Range, Variance, Standard Deviation

Created:September 2, 2024
Last Updated:July 29, 2025

This Range, Variance, and Standard Deviation Calculator helps you analyze the spread and variability of your data distribution. It calculates the range (difference between maximum and minimum values), variance (average squared deviation from the mean), and standard deviation (square root of variance), helping you understand how dispersed your data points are from their average. The calculator also provides a boxplot to visualize the distribution of your data, an error bar plot to show the mean with standard deviation, plus comprehensive step-by-step breakdowns of all calculations for learning purposes.

Quick Calculator

Need a quick calculation? Enter your numbers below:

Calculator

1. Load Your Data

2. Select Columns & Options

Related Calculators

Learn More

Range

Definition

The range is the difference between the largest and smallest values in a dataset, measuring the total spread of values.

Formula

Range=xmaxxmin\text{Range} = x_{max} - x_{min}

Example

For the numbers: 2,4,7,8,112, 4, 7, 8, 11

Range=112=9\text{Range} = 11 - 2 = 9

Key Points

  • Simple to calculate but sensitive to outliers
  • Only uses two values, ignoring all values in between

Variance

Definition

The variance measures how far a set of numbers are spread out from their mean. It's calculated as the average squared difference from the mean.

Formula

Sample Variance:

s2=i=1n(xixˉ)2n1s^2 = \frac{\sum_{i=1}^{n} (x_i - \bar{x})^2}{n-1}

Population Variance:

σ2=i=1N(xiμ)2N\sigma^2 = \frac{\sum_{i=1}^{N} (x_i - \mu)^2}{N}

Example

For the numbers: 2,4,4,62, 4, 4, 6

Mean = 4

s2=(24)2+(44)2+(44)2+(64)241=4+0+0+43=832.67\begin{align*} s^2 &= \frac{(2-4)^2 + (4-4)^2 + (4-4)^2 + (6-4)^2}{4-1} \\ &= \frac{4 + 0 + 0 + 4}{3} = \frac{8}{3} \approx 2.67 \end{align*}

Key Points

  • Uses squared differences, making it sensitive to outliers
  • Units are squared (e.g., if data is in meters, variance is in meters squared)

Standard Deviation

Definition

The standard deviation is the square root of the variance, providing a measure of spread in the same units as the original data.

Formula

Sample Standard Deviation:

s=i=1n(xixˉ)2n1s = \sqrt{\frac{\sum_{i=1}^{n} (x_i - \bar{x})^2}{n-1}}

Population Standard Deviation:

σ=i=1N(xiμ)2N\sigma = \sqrt{\frac{\sum_{i=1}^{N} (x_i - \mu)^2}{N}}

Example

Using the previous variance example:

s=2.671.63s = \sqrt{2.67} \approx 1.63

Key Points

  • In same units as original data, making it more interpretable than variance
  • Approximately 68% of data falls within one standard deviation of the mean in a normal distribution

Interactive Visualizations

Explore how Range, Variance, and Standard Deviation measure the spread of your data. Click the buttons to generate different data patterns and see how each measure responds.

Generate Sample Data

Mean
Range
Max - Min
Variance
Avg Squared Dev
Std Deviation
√Variance

Visual Representation

Click the buttons above to see how different data distributions affect these measures

Click a button above to generate sample data

Range

Highlighted area

Shows the total spread from minimum to maximum value. Simple but sensitive to outliers.

Variance

Square areas

Variance is the average area of all squares. Each square area = (data point - mean)². Large deviations create huge areas.

Std Deviation

√(Average square area)

Standard deviation is the square root of the average area of all squares. Each square's side length shows individual deviation.

💡 Try This:

  • Individual Squares: Each square's side length = |data point - mean|, area = (data point - mean)²
  • Standard Deviation: √(average area of all squares) - this "typical" deviation in original units
  • Tight Distribution: Notice how small squares and short range indicate low variability
  • With Outliers: Watch how extreme values create huge squares, dramatically increasing variance
  • Add Points: Observe how each new point affects all three measures differently

Calculating Range, Variance, and Standard Deviation in R, Python, and Excel

R with tidyverse package

R
library(tidyverse)

tips <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/tips.csv")

spread_measures <- tips |> 
  summarise(
    mean = mean(tip),
    min = min(tip),
    max = max(tip),
    range = max - min,
    IQR = IQR(tip),
    sample_var = var(tip),
    sample_sd = sd(tip),
    pop_var = var(tip) * (n() - 1) / n(),
    pop_sd = sqrt(pop_var)
  )

print(spread_measures)

#      mean min max range    IQR sample_var sample_sd  pop_var pop_sd
# 1 2.998279   1  10     9 1.5625   1.914455  1.383638 1.906609 1.3808

# boxplot
ggplot(tips, aes(x = "", y = tip)) +
  geom_boxplot(fill = "steelblue") +
  labs(
    title = "Boxplot of Tips",
    y = "Tip Amount"
  ) +
  theme_minimal()

# error bar plot
ggplot(spread_measures, aes(x = "", y = mean, ymin = mean - sample_sd, ymax = mean + sample_sd)) +
  geom_errorbar(width = 0.2, color = "red") +
  geom_point(aes(y = mean), color = "red", size = 3) +
  labs(
    title = "Mean and Standard Deviation of Tips",
    y = "Tip Amount"
  ) +
  theme_minimal()

Python with pandas package

Python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

# Load the dataset
tips = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/tips.csv")

# Calculate spread measures
spread_measures = {
    'mean': tips['tip'].mean(),
    'min': tips['tip'].min(),
    'max': tips['tip'].max(),
    'range': tips['tip'].max() - tips['tip'].min(),
    'IQR': tips['tip'].quantile(0.75) - tips['tip'].quantile(0.25),
    'sample_var': tips['tip'].var(ddof=1),  # Sample variance (n-1)
    'sample_sd': tips['tip'].std(ddof=1),   # Sample standard deviation
    'pop_var': tips['tip'].var(ddof=0),     # Population variance (n)
    'pop_sd': tips['tip'].std(ddof=0)       # Population standard deviation
}

# Display results
spread_df = pd.DataFrame([spread_measures])
print(spread_df)

# Create visualizations
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))

# boxplot
sns.boxplot(y=tips['tip'], ax=ax1, color='steelblue')
ax1.set_title('Boxplot of Tips')
ax1.set_ylabel('Tip Amount')
ax1.set_xlabel('')

# error bar plot
mean_val = spread_measures['mean']
sd_val = spread_measures['sample_sd']
ax2.errorbar(x=[0], y=[mean_val], yerr=[sd_val], 
             fmt='o', color='red', capsize=5, capthick=2)
ax2.set_title('Mean and Standard Deviation of Tips')
ax2.set_ylabel('Tip Amount')
ax2.set_xlim(-0.5, 0.5)
ax2.set_xticks([])

plt.tight_layout()
plt.show()

Excel with built-in functions

Excel
' Excel Formulas for Calculating Spread Measures
' Assuming your data is in column A (A1:A244 for tips dataset)

' Basic Statistics
Mean:           =AVERAGE(A:A)
Minimum:        =MIN(A:A)
Maximum:        =MAX(A:A)
Range:          =MAX(A:A) - MIN(A:A)

' Quartiles and IQR
Q1 (25th):      =QUARTILE(A:A, 1)
Q3 (75th):      =QUARTILE(A:A, 3)
IQR:            =QUARTILE(A:A, 3) - QUARTILE(A:A, 1)

' Variance and Standard Deviation
Sample Var:     =VAR.S(A:A)     ' or =VAR(A:A) in older Excel
Sample SD:      =STDEV.S(A:A)   ' or =STDEV(A:A) in older Excel
Population Var: =VAR.P(A:A)     ' or =VARP(A:A) in older Excel  
Population SD:  =STDEV.P(A:A)   ' or =STDEVP(A:A) in older Excel

' Step-by-Step Manual Calculation (if data in A1:A10)
' 1. Calculate mean in cell B1
=AVERAGE(A1:A10)

' 2. Calculate deviations in column C (C1:C10)
=A1-$B$1    ' Copy this formula down

' 3. Calculate squared deviations in column D (D1:D10)  
=C1^2       ' Copy this formula down

' 4. Sum of squared deviations in cell E1
=SUM(D1:D10)

' 5. Sample variance in cell F1
=E1/(COUNT(A1:A10)-1)

' 6. Sample standard deviation in cell G1  
=SQRT(F1)

' For Creating Charts:
' - Select your data range
' - Insert > Charts > Box and Whisker (Excel 2016+)
' - For error bars: Insert > Charts > Column Chart, then add error bars