Randomization supports a causal comparison when assignment, exposure, outcomes and interference follow the declared design.
Randomized assignment: check balance and retain every assigned unit
Lock the unit
If a learner can return from multiple devices, assign by stable learner key rather than page view. Record assignment once and keep it fixed. Shared family accounts or classroom sessions can create interference, so decide whether the cluster should instead be a classroom. The randomization unit also governs uncertainty calculations.
Inspect sample ratios
Compare observed assigned counts with the intended allocation, including missing and excluded units. A large imbalance may indicate a routing or logging defect. Baseline covariate checks can catch an implementation error, but a favorable balance table does not prove perfect randomization, and a small chance difference does not justify reshuffling outcomes after the fact.
Keep noncompliers
Some learners assigned the new panel may not see it because they leave before rendering. The primary intention-to-treat comparison keeps them in their assigned group. Restricting analysis to exposed learners conditions on post-assignment behavior. Report exposure rates and diagnose failures separately. The estimand changes if a treatment-received effect is later sought.
Exercise a release fixture
Assign 47 learners to the new panel and 53 to control under a 50/50 plan. Compare outcome collection and exposure counts for both groups. Add a duplicate assignment event and a learner with missing completion status. The analysis should keep one assigned record, flag the missing outcome and avoid silently replacing it with a zero.
Implementation
def assigned_group_rates(assigned_rows):
groups = {"treatment": {"assigned": 0, "observed": []},
"control": {"assigned": 0, "observed": []}}
seen_learners = set()
for row in assigned_rows:
learner_id = row["learner_id"]
if learner_id in seen_learners or row["group"] not in groups:
raise ValueError("duplicate learner or unknown group")
seen_learners.add(learner_id)
group = groups[row["group"]]
group["assigned"] += 1
if row["completed"] is not None:
if row["completed"] not in (0, 1):
raise ValueError("invalid completion outcome")
group["observed"].append(row["completed"])
return {name: {"assigned": group["assigned"],
"missing": group["assigned"] - len(group["observed"]),
"observed_rate": (sum(group["observed"]) / len(group["observed"])
if group["observed"] else None)}
for name, group in groups.items()}Performance and operating cost
Scanning N assignment rows costs O(N) expected time and O(N) state for uniqueness and observed outcomes. The function exposes missing groups as None; a full study must also report missing-outcome counts by assignment and assess their effect on the decision.
Common Mistakes
- Do not analyze only learners who actually saw the panel as the primary randomized contrast.
- Do not merge duplicate assignment events into extra learners.
- Do not hide group-specific missing outcomes.
Read next
- Causal estimands: name the unit, treatment and missing counterfactual
- Sensitivity and placebo checks: state how the causal claim could fail
- Experiment design: assign the right unit and guard against interference
- Implicit feedback: distinguish preference from what the system exposed
Continue the workflow: Experiment integrity: sample-ratio mismatch and A/A checks.
