# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# Fluorescence of a marker on gated cells from WT and KO mice stained and acquired on 3 days (2 mice per genotype per day).
import numpy as np
DAYS, PER_DAY, EVENTS = 3, 2, 1000

def study(rng, ratio=0.8, sd_day=0.30, sd_mouse=0.12, sd_cell=0.8, events=EVENTS):
    """Rows (day, mouse, genotype, fluorescence per event). Day effects (instrument settings, staining batch) shift
    every mouse that day on the log scale; KO multiplies the median fluorescence by `ratio`."""
    out = []
    for day in range(1, DAYS + 1):
        dshift = rng.normal(0, sd_day)
        for g in ("WT", "KO"):
            for k in range(PER_DAY):
                mu = np.log(2000) + dshift + (np.log(ratio) if g == "KO" else 0) + rng.normal(0, sd_mouse)
                out.append((day, f"{g}{(day - 1) * PER_DAY + k + 1}", g, np.exp(mu + rng.normal(0, sd_cell, events))))
    return out
