BRAGA

02 Writing02-02 Notes02-02-353

Standard Error of the Mean (SEM)

Published 16 Apr 20265 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples
SE=σnSE = \frac{\sigma}{\sqrt{n}}
(1)

Deep Breakdown

What it tells me (Situation Awareness): The Standard Error of the Mean quantifies how much the sample mean xˉ\bar{x} is expected to vary across different random samples of size nn drawn from a population with standard deviation σ\sigma. It is NOT the spread of individual data points (that is σ\sigma) — it is the spread of the sampling distribution of the mean. SEM is the building block for all inferential statistics: confidence intervals, t-tests, z-tests, and A/B test power calculations all rely on it.

Flowchart

Know populationstd dev sigma(or estimate withsample s)Know samplesize nCompute SE =sigma / sqrt(n)SE is the stddev of thesamplingdistribution ofx-barUse SE in: CI =x-bar +/- Z * SEUse SE in: t =(x-bar - mu_0) /SELarger n →smaller SE →more preciseestimates

Real-world use

Where it is used

Whenever you compute a sample mean and want to quantify how precise that estimate is: reporting mean conversion rate from an A/B test, estimating mean revenue per user, comparing two campaign means.

Problem it solves

A single sample mean is a point estimate with uncertainty. SEM quantifies that uncertainty: it tells you the typical distance between your sample mean and the true population mean.

How it solves the problem

By the Central Limit Theorem, the sampling distribution of xˉ\bar{x} is approximately N(μ,σ2/n)\mathcal{N}(\mu, \sigma^2/n). The standard deviation of this sampling distribution is σ/n\sigma / \sqrt{n} — the SEM. Larger nn compresses this distribution, giving more precise estimates.

Example in a business

A DA runs an A/B test with 500 users per group. The sample mean revenue is xˉ=12.50\bar{x} = 12.50 with population σ=8.00\sigma = 8.00. The SEM =8/500≈0.36= 8/\sqrt{500} \approx 0.36 tells them the typical precision of this estimate. The 95% CI is 12.50±1.96×0.36=[11.79,13.21]12.50 \pm 1.96 \times 0.36 = [11.79, 13.21].

The formula, piece by piece

Symbol Meaning
SESE Standard Error of the Mean
σ\sigma Population standard deviation (or sample ss if σ\sigma unknown)
n\sqrt{n} Square root of sample size
nn Number of observations

Full formula: SE=σnSE = \dfrac{\sigma}{\sqrt{n}} When σ\sigma is unknown (almost always in practice): SE^=sn\hat{SE} = \dfrac{s}{\sqrt{n}}

The formula in words

"The standard error of the mean equals the population standard deviation divided by the square root of the sample size." Doubling the sample size reduces the SEM by factor 2≈1.41\sqrt{2} \approx 1.41; quadrupling nn halves the SEM.

Critical Concepts

  • SEM vs SD: SD measures spread of individual data; SEM measures precision of the sample mean. Larger nn does NOT reduce SD — it reduces SEM.
  • n\sqrt{n} rule: SEM shrinks as 1/n1/\sqrt{n}, not 1/n1/n. To halve SEM, you need 4x more data.
  • Unknown σ\sigma: in practice use ss (sample SD) and a t-distribution for inference.
  • CLT requirement: SEM-based inference assumes the sampling distribution of xˉ\bar{x} is approximately Normal — valid for n≥30n \ge 30 for most distributions.

Step-by-step calculation (tiny example)

Sample of n=25n=25 daily revenues; population σ=100\sigma = 100 EUR.

Step 1: Identify sigma and n σ=100\sigma = 100, n=25n = 25

Step 2: Compute sqrt(n) 25=5\sqrt{25} = 5

Step 3: Divide SE=100/5=20SE = 100 / 5 = 20 EUR

Step 4: Interpret The sample mean xˉ\bar{x} is expected to be within about ±20\pm 20 EUR of the true population mean μ\mu (one standard error).

Code examples

Beginner example (Python)

python
import numpy as np

# Daily revenue data (small sample)
revenues = [85, 92, 110, 78, 105, 95, 88, 101, 97, 103]
n = len(revenues)
sample_mean = np.mean(revenues)
sample_std = np.std(revenues, ddof=1)   # sample SD (Bessel correction)
sem = sample_std / np.sqrt(n)
print(f"n = {n}")
print(f"Sample mean = {sample_mean:.2f}")
print(f"Sample SD = {sample_std:.2f}")
print(f"SEM = {sem:.4f}")

Beginner example (R)

r
revenues <- c(85, 92, 110, 78, 105, 95, 88, 101, 97, 103)
n <- length(revenues)
sample_mean <- mean(revenues)
sample_sd <- sd(revenues)  # R's sd() uses n-1 by default
sem <- sample_sd / sqrt(n)
cat("n :", n, "\n")
cat("Sample mean:", round(sample_mean, 2), "\n")
cat("Sample SD :", round(sample_sd, 2), "\n")
cat("SEM :", round(sem, 4), "\n")

Professional example (Python)

python
import numpy as np
import pandas as pd
from scipy import stats


def compute_sem_and_ci(
    data: np.ndarray,
    confidence_level: float = 0.95,
) -> dict[str, float]:
    # Compute sample mean, SEM, and t-based confidence interval.
    n = len(data)
    sample_mean = float(np.mean(data))
    sample_std = float(np.std(data, ddof=1))
    sem = sample_std / np.sqrt(n)
    alpha = 1.0 - confidence_level
    t_critical = stats.t.ppf(1 - alpha / 2, df=n - 1)
    margin = t_critical * sem
    return {
        "n": n,
        "mean": round(sample_mean, 4),
        "std": round(sample_std, 4),
        "sem": round(sem, 4),
        "t_critical": round(t_critical, 4),
        "ci_lower": round(sample_mean - margin, 4),
        "ci_upper": round(sample_mean + margin, 4),
        "confidence_level": confidence_level,
    }


def sem_sample_size_table(sigma: float, target_sems: list[float]) -> pd.DataFrame:
    # Required sample sizes to achieve target SEM values.
    # n = (sigma / target_SE)^2
    rows = []
    for target_se in target_sems:
        n_required = int(np.ceil((sigma / target_se) ** 2))
        rows.append({"target_SE": target_se, "required_n": n_required})
    return pd.DataFrame(rows)


if __name__ == "__main__":
    rng = np.random.default_rng(seed=42)
    revenue_data = rng.normal(loc=120.0, scale=30.0, size=200)
    stats_dict = compute_sem_and_ci(revenue_data, confidence_level=0.95)
    print("Mean estimate and 95% CI:")
    for key, val in stats_dict.items():
        print(f" {key}: {val}")
    print("\nSample size requirements (sigma=30):")
    print(sem_sample_size_table(sigma=30.0, target_sems=[5.0, 3.0, 2.0, 1.0]))

Source: domain knowledge

#probability-statistics#multivariable-statistics-and-information#inferential-statistics-hypothesis-testing

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close