"""Teaching simulation: separate between-group contrasts at two times.
Not published study data. Both groups contain 60 people at each time.
Normal approximation: difference +/- 1.96 * sqrt(sd_a**2/n_a+sd_b**2/n_b).
These are not an interaction test or an analysis of change over time.
"""
from math import sqrt, isclose

for label, mean_a, mean_b in [('immediate', 16.0, 14.0), ('new_task_day7', 15.2, 15.0)]:
    n_a = n_b = 60
    sd_a = sd_b = 3.0
    difference = mean_a - mean_b
    standard_error = sqrt(sd_a**2 / n_a + sd_b**2 / n_b)
    lower, upper = difference - 1.96*standard_error, difference + 1.96*standard_error
    print(f'{label}: difference={difference:.2f}, approximate 95% CI [{lower:.2f}, {upper:.2f}]')
    assert isclose(standard_error, sqrt(0.3))
assert 32 / 40 == 0.8
