Variance and Standard Deviation Calculator
Use this unified calculator to calculate variance and standard deviation for both ungrouped (raw) data and grouped (frequency distribution) data.
Quick Start
Choose your data type, enter your values, and click Calculate:
| Variance and Standard Deviation Calculator | |
|---|---|
| Data Type | Ungrouped (Raw Data) Grouped (Frequency Distribution) |
| Enter the X Values (Separated by comma,) | |
| Type of Frequency Distribution | DiscreteContinuous |
| Enter the Classes for X (Separated by comma,) | |
| Enter the frequencies (f) (Separated by comma,) | |
| Results | |
| Number of Observations (N): | |
| Sample Mean : ($\overline{x}$) | |
| Sample Variance : ($s^2_x$) | |
| Sample Standard Deviation : ($s_x$) | |
How to Use This Calculator
For Ungrouped (Raw) Data
Step 1: Select “Ungrouped (Raw Data)” as your data type
Step 2: Enter your data values separated by commas (e.g., 22, 25, 24, 23, 24, 20)
Step 3: Click “Calculate”
Results will show:
- Number of observations (N)
- Sample mean
- Sample variance
- Sample standard deviation
For Grouped (Frequency Distribution) Data
Step 1: Select “Grouped (Frequency Distribution)” as your data type
Step 2: Choose frequency distribution type:
- Discrete: For individual values (e.g., 2, 3, 4, 5, 6)
- Continuous: For class intervals (e.g., 10-20, 20-30, 30-40)
Step 3: Enter class values or intervals separated by commas
Step 4: Enter the corresponding frequencies separated by commas
Step 5: Click “Calculate”
Results will show:
- Number of observations (N)
- Sample mean
- Sample variance
- Sample standard deviation
Formulas & Theory
Understanding Variance and Standard Deviation
Variance measures how spread out data values are from their mean. It’s the average of the squared differences from the mean.
Standard Deviation is the square root of variance, expressing spread in the same units as the original data.
For Ungrouped Data
Sample Mean
$$\overline{x} = \frac{1}{n}\sum_{i=1}^{n}x_i = \frac{x_1 + x_2 + \cdots + x_n}{n}$$
Sample Variance
$$s_x^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i - \overline{x})^2$$
Computational form (easier to calculate):
$$s_x^2 = \frac{1}{n-1}\left(\sum_{i=1}^{n}x_i^2 - \frac{\left(\sum_{i=1}^n x_i\right)^2}{n}\right)$$
Sample Standard Deviation
$$s_x = \sqrt{s_x^2}$$
Where:
- $x_i$ = individual data values
- $n$ = number of observations
- $\overline{x}$ = sample mean
- Division by $(n-1)$ gives unbiased estimate (called Bessel’s correction)
For Grouped Data
Sample Mean
$$\overline{x} = \frac{1}{N}\sum_{i=1}^{k}f_i x_i$$
Where:
- $x_i$ = class midpoint (for continuous) or class value (for discrete)
- $f_i$ = frequency of class i
- $N = \sum f_i$ = total number of observations
- For continuous: $x_i = \frac{\text{lower limit} + \text{upper limit}}{2}$
Sample Variance
$$s_x^2 = \frac{1}{N-1}\sum_{i=1}^{k}f_i(x_i - \overline{x})^2$$
Computational form:
$$s_x^2 = \frac{1}{N-1}\left(\sum_{i=1}^{k}f_i x_i^2 - \frac{\left(\sum_{i=1}^k f_i x_i\right)^2}{N}\right)$$
Sample Standard Deviation
$$s_x = \sqrt{s_x^2}$$
Worked Examples
Example 1: Ungrouped Data - Student Ages
Data: Ages of 6 students: 22, 25, 24, 23, 24, 20
Solution:
Step 1: Create calculation table
| $x_i$ | $x_i^2$ |
|---|---|
| 22 | 484 |
| 25 | 625 |
| 24 | 576 |
| 23 | 529 |
| 24 | 576 |
| 20 | 400 |
| Sum: 138 | Sum: 3190 |
Step 2: Calculate Mean $$\overline{x} = \frac{138}{6} = 23 \text{ years}$$
Step 3: Calculate Variance $$s_x^2 = \frac{1}{5}\left(3190 - \frac{(138)^2}{6}\right) = \frac{1}{5}(3190 - 3174) = \frac{16}{5} = 3.2$$
Step 4: Calculate Standard Deviation $$s_x = \sqrt{3.2} = 1.7889 \text{ years}$$
Interpretation: Ages vary by an average of 1.79 years from the mean of 23 years.
Example 2: Ungrouped Data - Hourly Wages
Data: Hourly wages of 10 employees: 20, 21, 24, 25, 18, 22, 24, 22, 20, 22 (dollars)
Solution:
| $x_i$ | $x_i^2$ |
|---|---|
| 20 | 400 |
| 21 | 441 |
| 24 | 576 |
| 25 | 625 |
| 18 | 324 |
| 22 | 484 |
| 24 | 576 |
| 22 | 484 |
| 20 | 400 |
| 22 | 484 |
| Sum: 218 | Sum: 4794 |
Mean: $\overline{x} = \frac{218}{10} = 21.8$ dollars
Variance: $s_x^2 = \frac{1}{9}\left(4794 - \frac{(218)^2}{10}\right) = \frac{1}{9}(4794 - 4752.4) = 4.6222$
Standard Deviation: $s_x = \sqrt{4.6222} = 2.1499$ dollars
Interpretation: Hourly wages vary by about $2.15 from the average of $21.80.
Example 3: Grouped Data - Car Accidents
Data: Daily car accidents at intersection during April
| Accidents ($x$) | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|
| Days ($f$) | 9 | 11 | 6 | 3 | 1 |
Solution:
Step 1: Create calculation table
| $x_i$ | $f_i$ | $f_i x_i$ | $f_i x_i^2$ |
|---|---|---|---|
| 2 | 9 | 18 | 36 |
| 3 | 11 | 33 | 99 |
| 4 | 6 | 24 | 96 |
| 5 | 3 | 15 | 75 |
| 6 | 1 | 6 | 36 |
| Total | N=30 | 96 | 342 |
Step 2: Calculate Mean $$\overline{x} = \frac{96}{30} = 3.2 \text{ accidents/day}$$
Step 3: Calculate Variance $$s_x^2 = \frac{1}{29}\left(342 - \frac{(96)^2}{30}\right) = \frac{1}{29}(342 - 307.2) = \frac{34.8}{29} = 1.2 \text{ accidents}^2$$
Step 4: Calculate Standard Deviation $$s_x = \sqrt{1.2} = 1.095 \text{ accidents}$$
Interpretation: Daily accidents vary by about 1.10 from the mean of 3.2 accidents/day.
Example 4: Grouped Data (Continuous) - Hospital Stay Length
Data: Length of stay (days) for 50 patients
| Length of Stay | 5-10 | 10-15 | 15-20 | 20-25 | 25-30 |
|---|---|---|---|---|---|
| Number of Patients | 8 | 15 | 18 | 6 | 3 |
Solution:
Step 1: Create calculation table
| Class | Midpoint ($x_i$) | $f_i$ | $f_i x_i$ | $f_i x_i^2$ |
|---|---|---|---|---|
| 5-10 | 7.5 | 8 | 60 | 450 |
| 10-15 | 12.5 | 15 | 187.5 | 2343.75 |
| 15-20 | 17.5 | 18 | 315 | 5512.5 |
| 20-25 | 22.5 | 6 | 135 | 3037.5 |
| 25-30 | 27.5 | 3 | 82.5 | 2268.75 |
| Total | N=50 | 780 | 13612.5 |
Step 2: Calculate Mean $$\overline{x} = \frac{780}{50} = 15.6 \text{ days}$$
Step 3: Calculate Variance $$s_x^2 = \frac{1}{49}\left(13612.5 - \frac{(780)^2}{50}\right) = \frac{1}{49}(13612.5 - 12168) = \frac{1444.5}{49} = 29.48$$
Step 4: Calculate Standard Deviation $$s_x = \sqrt{29.48} = 5.43 \text{ days}$$
Interpretation: Hospital stays vary by about 5.43 days from the mean of 15.6 days.
Interpreting Variance and Standard Deviation
What Variance Tells You
- Measures spread of data around the mean
- Larger variance = data more spread out
- Units are squared (e.g., dollars² if original is dollars)
- Less intuitive due to squared units
What Standard Deviation Tells You
- Measures spread in original units
- More interpretable than variance
- Shows typical distance from mean
- Used in many statistical applications (e.g., normal distribution, confidence intervals)
The Relationship to Normal Distribution
For normally distributed data:
- 68% of data within 1 standard deviation of mean
- 95% of data within 2 standard deviations of mean
- 99.7% of data within 3 standard deviations of mean
Example: If mean test score = 75 and SD = 5:
- 68% of students score between 70-80
- 95% of students score between 65-85
Key Differences: Ungrouped vs. Grouped Data
| Aspect | Ungrouped Data | Grouped Data |
|---|---|---|
| Data Format | Individual raw values | Classes with frequencies |
| Information Loss | None - exact values known | Some - exact values not known |
| Calculation | Direct from values | Using class midpoints |
| Accuracy | Exact values | Approximate values |
| When to Use | Small datasets | Large datasets, already summarized |
| Formula | Simple summation | Weighted by frequencies |
When to Use Ungrouped vs. Grouped
Use Ungrouped Data Calculator When:
- You have individual raw data points
- Dataset is relatively small (< 100 values)
- Need exact variance and standard deviation
- All original values are available
- Examples: Quiz scores, lab measurements, small survey responses
Use Grouped Data Calculator When:
- Data already organized into classes/intervals
- Large dataset (1000+ values)
- Only frequency distribution available, not raw data
- Want to summarize large amounts of information
- Examples: Income ranges in a population, test score distributions across years
Common Mistakes to Avoid
❌ WRONG: Confusing variance and standard deviation ✓ RIGHT: Remember: SD = √Variance; SD is in original units, variance is squared
❌ WRONG: Using population formula (divide by n) instead of sample formula (divide by n-1) ✓ RIGHT: Use n-1 (Bessel’s correction) for sample data
❌ WRONG: Using ungrouped formula on grouped data with class intervals ✓ RIGHT: Use grouped data formula that accounts for frequencies and midpoints
❌ WRONG: Ignoring the data type (discrete vs continuous) for grouped data ✓ RIGHT: For continuous data, always use class midpoints
❌ WRONG: Assuming large variance means data is “bad” ✓ RIGHT: Variance is descriptive - interpret based on context and units
Related Calculators & Tutorials
Explore related dispersion measures:
Explore related central tendency:
Learn More: