# Data-generating model shared by make_data.py and simulation.py. Python 3.13, NumPy.
# Label-free protein log2 intensities, 5 control and 5 treated samples, with missing values that are more likely at
# low intensity (missing not at random, as near the detection limit).
import numpy as np
PROTEINS, N, CHANGED = 1000, 5, 100

def study(rng, lfc=1.0):
    mean = rng.normal(25, 2.0, PROTEINS); sd = 0.25
    eff = np.zeros(PROTEINS); eff[:CHANGED] = lfc * np.tile([1, -1], CHANGED // 2)
    ctl = mean + rng.normal(0, sd, (N, PROTEINS)); trt = mean + eff + rng.normal(0, sd, (N, PROTEINS))
    x = np.vstack([ctl, trt])
    p_miss = 1 / (1 + np.exp((x - 23.0) / 0.6))          # 50% missing at log2 intensity 23, rising below it
    x[rng.random(x.shape) < p_miss] = np.nan
    return x, eff
