# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# Scratch assay: wound width (µm) in 3 fields per well, 3 wells per condition, imaged at 0, 6, 12 and 24 h, in several
# independent experiments. Each wound edge moves at the cells' migration speed v (µm/h), so width falls by 2v per hour.
import numpy as np
TIMES = np.array([0, 6, 12, 24.0]); WELLS, FIELDS = 3, 3

def experiment(rng, drug_ratio=1.0, v=6.0, sd_day=0.15, sd_cond=0.08, sd_well=0.06, w0_mean=500, w0_sd=80, sd_meas=15):
    rows = []; day = rng.normal(0, sd_day)
    for cond, ratio in (("control", 1.0), ("drug", drug_ratio)):
        vc = v * ratio * np.exp(day + rng.normal(0, sd_cond))
        for w in range(WELLS):
            vw = vc * np.exp(rng.normal(0, sd_well))
            for f in range(FIELDS):
                w0 = rng.normal(w0_mean, w0_sd)                       # hand-made scratches vary in starting width
                for t in TIMES:
                    rows.append((cond, w + 1, f + 1, t, max(w0 - 2 * vw * t, 0) + rng.normal(0, sd_meas)))
    return rows
