Standard Error of the Mean (SEM)

Basics
BasicsInferenceCLTGoogleMetaJane Street

Problem

Implement standard_error_mean(x) returning the Standard Error of the Mean SEM=sn\text{SEM} = \frac{s}{\sqrt{n}}, where ss is the sample standard deviation (ddof=1).

Why It Matters: SEM quantifies how uncertain our sample mean is as an estimate of the true population mean—shrinking as 1/n1 / \sqrt{n} when you collect more data.

Function Signature

import numpy as np

def standard_error_mean(x) -> float:

Sample Input & Output

Example 1: 4-Element Sample

Input:

x = [2.0, 4.0, 4.0, 6.0]

Expected Output:

0.816497

Explanation: s = sqrt(8/3) ≈ 1.632993, sqrt(4) = 2.0, so SEM = 1.632993 / 2 ≈ 0.816497.

Example 2: Zero Variance Sample

Input:

x = [5.0, 5.0, 5.0, 5.0]

Expected Output:

0.0

Explanation: When every observation is identical, s = 0.0 so SEM = 0.0.

Constraints & Edge Cases

  • Return SEM as a Python float (len(x) >= 2).
  • Use ddof=1 for sample standard deviation.
  • Input length n >= 2.

Constraints & Evaluation Criteria

  • Return SEM as a Python float (`len(x) >= 2`).

Hints

Python 3
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
[2, 4, 6, 8]
Expected Output / Criteria
1.2910