Argumentation, Stance, and Persuasion › Randomized Exposure: Estimating an Effect
Language AI HandbookAll chapters The alternative design randomizes who is exposed to what. The study below is fictional: it is constructed for teaching, and it is not a finding about any real library, any real participant, or any real message. Its only purpose is to show what the estimate looks like and what it licenses.
The simulation assigns 240 hypothetical participants to read the board memo alone or to read the memo plus a two-minute structured argument. Both arms use the same 0 to 100 agreement scale. Each participant’s outcome is their immediate post-exposure score minus their pre-exposure score.
PythonIn [30]Expand
N_PARTICIPANTS = 240
rng_study = np.random.default_rng(RNG_SEED + 1)
arm = rng_study.integers(0, 2, size=N_PARTICIPANTS)
pre = np.clip(rng_study.normal(50, 15, size=N_PARTICIPANTS), 0, 100)
noise = rng_study.normal(0, 9, size=N_PARTICIPANTS)
post_memo = np.clip(pre + 1.5 + noise, 0, 100)
post_argument = np.clip(pre + 6.0 + noise, 0, 100)
post = np.where(arm == 1, post_argument, post_memo)
change = post - pre
simulated_sample_effect = (post_argument - post_memo).mean()ConsoleOut [31]Expand
treatment arm n=122 mean pre 46.8 mean change +8.14 control arm n=118 mean pre 49.4 mean change +0.18 difference in mean change: +7.95 points on a 0-100 scale sample effect from both simulated outcomes: +4.46 points
The treatment arm’s pre-exposure mean is about 2.56 points below the control arm’s mean in this draw. The estimate subtracts the group's control mean change from the treatment mean change. The simulator can also compute the unobserved assignment outcome for each individual. It keeps that individual’s noise draw fixed across the two possible assignments and clips each outcome to the agreement scale. The resulting average effect for these 240 simulated individuals differs slightly from the 4.5-point contrast before clipping.
PythonIn [32]Expand
def permutation_test(values, groups, n_perm=10000, seed=RNG_SEED + 2):
gen = np.random.default_rng(seed)
observed = values[groups == 1].mean() - values[groups == 0].mean()
exceed = 0
for _ in range(n_perm):
shuffled = gen.permutation(groups)
stat = values[shuffled == 1].mean() - values[shuffled == 0].mean()
if abs(stat) >= abs(observed):
exceed += 1
return float(observed), (exceed + 1) / (n_perm + 1)
def bootstrap_ci(values, groups, n_boot=5000, seed=RNG_SEED + 3):
gen = np.random.default_rng(seed)
t_idx = np.flatnonzero(groups == 1)
c_idx = np.flatnonzero(groups == 0)
stats = np.empty(n_boot)
for b in range(n_boot):
t_sample = gen.choice(t_idx, size=len(t_idx), replace=True)
c_sample = gen.choice(c_idx, size=len(c_idx), replace=True)
stats[b] = values[t_sample].mean() - values[c_sample].mean()
return np.percentile(stats, [2.5, 97.5])
def mean_ci(values, n_boot=5000, seed=RNG_SEED + 4):
gen = np.random.default_rng(seed)
means = np.array(
[
gen.choice(values, size=len(values), replace=True).mean()
for _ in range(n_boot)
]
)
return np.percentile(means, [2.5, 97.5])ConsoleOut [33]Expand
difference in mean change: +7.95 95% bootstrap interval: [+5.80, +10.15] permutation p-value: 0.0001 control mean change 95% CI: [-1.44, +1.74] treated mean change 95% CI: [+6.65, +9.64]
In this simulated assignment, the contrast is 7.95 points and the within-arm percentile bootstrap interval for the contrast is 5.80 to 10.15 points. This approximate interval resamples observed participants within each arm and does not contain the oracle effect for these 240 simulated participants. Its nominal level does not establish exact coverage over repeated treatment assignments for these fixed participants. The randomization test compares the absolute contrast with reassignments having the observed arm sizes under the sharp null of zero effect for every participant. The 10,000-reassignment test yields 0.0001 after the plus-one adjustment and rounding.
The outcome only describes immediate self-reported agreement in the fictional setup.
There is no follow-up measurement. Generalization would require evidence from other messages, populations and settings. The estimate leaves message quality and individual mechanisms as separate questions.
VisualizationOut [34]Expand

The plot shows the two arm means and their individual intervals. For uncertainty about the difference, use the separately computed contrast interval of 5.80 to 10.15 points.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!