# Numerical integration with measurement errors: what scheme to use?

I have an unknown 'smooth' function that is sampled at some $$n$$ equally spaced locations $$x_i$$ between $$0$$ and $$1$$, with some measurement values $$f(x_i)=y_i$$, but each has some Gaussian uncertainty ($$(\sigma_y)_i$$). I am interested in the integral $$I=\int f\; \mathrm{d}x$$.

One way to get it is to use a Riemann sum, which would yield $$I=\frac{1}{N}\sum_i x_i$$. (Or if the errors are different, the sum should be weighted.) But Riemann integration just assumes a piecewise function which is not a good approximation if there is some curvature in the function.

Another way would be to use a higher order method, for example Simpson's rule. These are higher order, but have worse behaviour with large uncertainties: if one measurement is off, the quadratic interpolation would be much more wrong than a linear interpolation, and hence the integral of the quadratic interpolation would be worse than the integral of the linear interpolation.

So there seems to be a tradeoff: if there are high uncertainties, use lower-order methods, and if the uncertainties are low, use higher order methods. But how to choose? What would be the best way of estimating $$I$$ (and its uncertainty)?

One way would be to parametrize the 'smooth function', estimate the parameters and calculate the integral of the parametrization. But then, if there is not an obvious model, what parametrization should I use? (And what priors on the parameters?)

• Do you have data (x,y) that you can plot or is this just a general function? Are you wanting to perform the integration over limits or do you want the general solution? Jun 5, 2020 at 20:34
• I have data points (x,y), know nothing about the function, except that it should be smooth. I want to know the integral of the function that generates the data points y=f(x). I forgot to mention, the integral is between 0 and 1, ie the extent of the data points x. Of course you can always renormalize your data this way. Jun 5, 2020 at 20:52

I think what you need is the smoothing spline. You'd be minimizing the following functional by looking for a function $$\hat f(x)$$: $$\sum_{i=1}^n \{y_i - \hat f(x_i)\}^2 + \lambda \int \hat f''(x)^2 \,dx.$$ Once you got the function, integrating it is yrivial for cubic or other polynomial splines.
$$\widehat{f}_h(x) = \frac{1}{n}\sum_{i=1}^n K_h (x - x_i) = \frac{1}{nh} \sum_{i=1}^n K\Big(\frac{x-x_i}{h}\Big),$$ Again, once you have a Kernel, integrating it is trivial.