# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# Trial-by-trial stimulus responses (ΔF/F: mean in the response window minus the pre-stimulus baseline, divided by the baseline)
# for neurons imaged in WT and KO mice.
import numpy as np
MICE, NEURONS, TRIALS = 5, 40, 20

def study(rng, ko_shift=0.0, mu=0.05, sd_mouse=0.04, sd_neuron=0.06, sd_trial=0.15, mice=MICE):
    """Rows (mouse, genotype, neuron, responses over trials). Each mouse has its own average response, each neuron its own
    response around its mouse's average, and each trial scatters around the neuron's response."""
    out = []
    for g in ("WT", "KO"):
        for m in range(mice):
            mm = mu + (ko_shift if g == "KO" else 0) + rng.normal(0, sd_mouse)
            for n in range(NEURONS):
                r = mm + rng.normal(0, sd_neuron)
                out.append((f"{g}{m + 1}", g, n + 1, r + rng.normal(0, sd_trial, TRIALS)))
    return out
