# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# Organoid size: in each independent differentiation batch, control and drug-treated organoids grow in 3 wells each,
# and every organoid in focus in a well is measured (cross-sectional area, um^2). Sizes are log-normal; batches differ
# a lot (both conditions together), the drug's apparent effect varies a little between batches, wells differ, and
# organoids vary widely within a well.
import numpy as np
WELLS = 3

def batch(rng, drug_ratio=1.0, area=40000, sd_batch=0.25, sd_int=0.08, sd_well=0.12, sd_org=0.6, per_well=20):
    rows = []; b = rng.normal(0, sd_batch)
    for cond, r in (("control", 1.0), ("drug", drug_ratio)):
        bc = b + rng.normal(0, sd_int)
        for w in range(WELLS):
            mu = np.log(area * r) + bc + rng.normal(0, sd_well); n = max(5, rng.poisson(per_well))
            rows += [(cond, w + 1, round(float(a))) for a in np.exp(mu + rng.normal(0, sd_org, n))]
    return rows
