UniformCubicTemplate

class ell1fit.templates.UniformCubicTemplate(coefficients, x0, dx, n_intervals)[source]

Bases: object

A pulse template that is callable and can score events in one pass.

Behaves as the plain phase -> density function every caller expects, so plotting and diagnostics are unaffected. The likelihood additionally uses loglike(), which fuses interpolation, flooring and the log-sum into a single traversal rather than three.

Methods Summary

__call__(phases)

Call self as a function.

loglike(phases[, weights, floor])

Total log-likelihood of phases under this template.

Methods Documentation

__call__(phases)[source]

Call self as a function.

loglike(phases, weights=None, floor=1e-12)[source]

Total log-likelihood of phases under this template.

The interpolation and clamp happen in one compiled pass; the logarithm and the sum are then left to numpy, which is both faster and more accurate than doing them element-by-element. Faster because numpy’s log is SIMD-vectorised, where a scalar loop calling log once per event is not – measured at roughly 0.6x, so fusing everything is a pessimisation. More accurate because np.sum accumulates pairwise, with error growing like log(N) rather than the N of a running total: at two million events that is a 30x smaller error than the loop this replaces.