Solution (source code)

= Solution

If spatial illumination is stable between the two sums, it acts just like the sensitivity factor: the mean ratio remains one but each <detector pixel> has a different shot-noise <variance>. A whole-image <standard deviation> is disproportionately influenced by faint <detector pixels>, so substituting a global <arithmetic mean> signal generally underestimates <detector conversion gain>. If the illumination pattern differs between the sums, their noise-free ratio is not constant; its structure adds apparent <variance> and causes a further systematic error.

\b[Use locally uniform signal bins or subregions, remove offsets, mask defective or saturated <detector pixels>, and propagate the local shot and read <variances>.] In the stable-pattern case a useful alternative to pooling raw ratios is the normalized difference
$$
U_i=\frac{A_i-B_i}{\sqrt{A_i+B_i}}.
$$
At high signal and negligible <read noise>, treating the denominator at its mean gives $\operatorname{Var}(U_i)\simeq(2N_i/g)/(2N_i)=1/g$, independent of the illumination. Thus a <variance> fit or $g\simeq1/\operatorname{Var}(U)$ can use a spatially varying flat without the arithmetic/harmonic mismatch. Measured noisy denominators cause higher-order corrections, so independent or smoothed signal estimates can be preferable. Fit and subtract a genuine changing illumination pattern before noise analysis, using sufficient smoothing not to fit away the random noise. Arbitrary flat-field normalization without propagating its noise does not by itself recover the original gain.