hist
hist copied to clipboard
[FEATURE] Interpolator
We should add an Interpolator class that can interpolate histograms.
Idea for usage:
# Linear interpolation
f = hist.interp.Linear(h)
x = f(2.3)
An Interpolator
would take a histogram, and would be callable, with the positional or keyword axes, and would return the interpolated value at that point, making the histogram act like a function. We could have a shortcut directly on the hist to do the above, but the design should be as seen above.
just as a consideration in pyhf we have a few interpolators, but often they are initialized with multiple hisotgrams
e.g.
f = Interp(hdown,hnom,hup)
x = f(2.3)
where f(1.0)==hup
, f(-1.0)==hdown
, f(0.0)==hnom
So these return histograms, rather than values?
yeah usually we're interested in interpolating between histograms so that you have a parametrised family of histograms, such that for each parameter value you get a full histogram.. for most of the interpolations you can also think of it as a single bin interpolation (returning a float) just applied to all bins
FWIW I like the idea of an interface such as hist.interp.Linear(h)
because it means interpolation stays separate from a histogram. You can then have hist.interp.Cubic(h)
or whatever else even fancier. It will also make it easier, I hope, to provide interpolation with error propagation, where it makes sense.