# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# A single-dose cell viability assay (for example MTT or CellTiter-Glo): in each independent experiment (a different
# day and passage) one 96-well plate holds 3 blank wells (medium only), 6 vehicle wells and 6 treated wells.
# The signal scale differs between experiments (SD 0.30 on the log scale), wells scatter around their experiment
# (6% coefficient of variation), and blanks read about 0.05. `ratio` is the treated/vehicle ratio of cell signal.
import numpy as np

def study(rng, experiments=4, ratio=1.0, sd_exp=0.30, cv_well=0.06, sd_ratio=0.08):
    rows = []
    for e in range(experiments):
        scale = 1.0 * np.exp(rng.normal(0, sd_exp)); r = ratio * np.exp(rng.normal(0, sd_ratio))   # experiment-specific
        for w in range(3):
            rows.append((f"E{e + 1}", "blank", w + 1, round(0.05 + rng.normal(0, 0.005), 4)))
        for cond, m in (("vehicle", 1.0), ("treated", r)):
            for w in range(6):
                rows.append((f"E{e + 1}", cond, w + 1, round(0.05 + scale * m * np.exp(rng.normal(0, cv_well)), 4)))
    return rows
