Simpson baseline integration for pulse-energy correction (source code)

= Simpson baseline integration for pulse-energy correction
{c}

\b[Simpson baseline integration for pulse-energy correction] subtracts a three-point estimate of integrated background from a measured gate integral. For a baseline $b(t)$ on $[0,T]$, <Simpson's rule> gives
$$
B_S=\frac T6[b(0)+4b(T/2)+b(T)],\qquad
\widehat U=\int_0^T P_{\rm measured}(t)\,dt-B_S.
$$
It is exact for a quadratic or cubic baseline, provided the three values represent background rather than pulse-contaminated samples. For a four-times differentiable baseline, the remainder is $\int_0^T b\,dt-B_S=-T^5b^{(4)}(\xi)/2880$ for some $0<\xi<T$.<NIST Digital Library of Mathematical Functions/3.5 Quadrature, subsection (ii) Simpson’s Rule>[equation3.5.6, elementary rule and fourth-derivative remainder]{ref}

For an original chosen quadratic background, take $T=6\,\mathrm{\mu s}$ with beginning, midpoint and end values $2$, $3$ and $2\,\mathrm{mW}$. Its integrated baseline is $16\,\mathrm{nJ}$, whereas endpoint averaging would give $12\,\mathrm{nJ}$. A raw gate integral of $116\,\mathrm{nJ}$ therefore gives $100\,\mathrm{nJ}$ after the three-point correction. Overestimating only the midpoint by $0.50\,\mathrm{mW}$ would subtract an extra $2\,\mathrm{nJ}$.

The <uncertainty of a three-point baseline integral> is separate from its quadrature error. With baseline-sample <covariance matrix> $C_b$ and $\mathbf w=(T/6)(1,4,1)^T$, its variance is $\mathbf w^TC_b\mathbf w$. Independent samples of common <standard uncertainty> $\sigma_b$ give $u(B_S)=T\sigma_b/\sqrt2$; a perfectly shared additive baseline error of the same uncertainty gives $T\sigma_b$ instead. Covariance terms cannot be discarded.<Guide to the expression of uncertainty in measurement by JCGM>[§5.2.2, equation13]{ref}

A matched blank acquisition or independently measured background can supply the midpoint. Historical NIST pulse-energy apparatus used before/after baselines for background and thermal-drift compensation.<Calibration Service for Low-level Pulsed-Laser Radiometers at 1.06 µm: Pulse Energy and Peak Power by Rodney W. Leonhardt>[§3.5, reference-standard processing; §7.2, Leakage Effect]{ref} The three-point example is an original extension, not a claim about that instrument's processing. Higher polynomial exactness does not compensate for an incorrectly identified baseline.