# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# Miniature EPSC amplitudes (pA) recorded from several neurons per mouse in WT and KO mice.
import numpy as np
MICE, CELLS, EVENTS = 5, 4, 200

def study(rng, ko_ratio=1.0, sd_mouse=0.10, sd_cell=0.15, sd_event=0.45, mice=MICE):
    """Rows (genotype, mouse, cell, amplitudes). Each mouse has its own typical amplitude, each cell its own around the mouse,
    and events within a cell are right-skewed (log-normal). KO multiplies the typical amplitude by `ko_ratio`."""
    out = []
    for g in ("WT", "KO"):
        for m in range(mice):
            mm = np.log(15.0) + (np.log(ko_ratio) if g == "KO" else 0) + rng.normal(0, sd_mouse)
            for c in range(CELLS):
                cm = mm + rng.normal(0, sd_cell)
                out.append((g, f"{g}{m + 1}", f"{g}{m + 1}-c{c + 1}", np.exp(cm + rng.normal(0, sd_event, EVENTS))))
    return out
