# Sampling arbitrary differential function with mean $0$ so that sample mean's deviation from $0$ is minimized

This might be a basic question but here it goes:

I have a differentiable (arbitrary) function $$f(t)$$ on some interval $$[0, T]$$ that has mean $$T^{-1}\int_0^T f(t) = 0$$. I want to sample a set $$S$$ of $$n > 1$$ points such that the sample average is as close to $$0$$ as possible, on average. I think I would formulate this as that I want to find the distribution $$p$$ from which to sample $$S$$ that minimizes the sample mean's expected deviation from $$0$$: $$p = \arg \min_{p'} \mathbb{E}_{S \sim p'}[|n^{-1}\sum_{t \in S}f(t)|]$$

My impression is that usually one wants to use uniform sampling to get a representative sample. But intuitively for this problem I feel like one would want to sample a random set of $$n$$ evenly spaced points, rather than uniform sampling of $$n$$ points. At least when I think of a function such as $$f(t) = \sin(t)$$. But I don't know if that is correct, if it is true in general, and how to formalize it?

The way your question is formulated, the function $$f$$ is fixed. In this case there is a root $$t_{\ast} \in [0,T]$$ of $$f$$ such that $$f(t_{\ast}) = 0$$. So the optimal distribution $$p$$ on $$[0,T]$$ would be the one that gives all mass to the value $$t_{\ast}$$, i.e. the Dirac measure corresponding to $$(t_{j}=t_{\ast})_{j=1,\dots,n}$$ (choose all sample points to equal $$t_{\ast}$$ with probability 1).

I suspect that this is not what you want, you rather want the same distribution $$p$$ to work for all/many/typical functions $$f$$ and the answer really depends on the way you (re-)formulate your question.

• Gaussian quadrature provides the optimal convergence rate in a certain sense depending on the smoothness of the function class considered. Again, this is "deterministic", so $$p$$ would be concentrated on one specific set of sample points.

• If you want a probabilistic approach, then you might define a probability distribution on the set of functions $$f$$ and try to minimize the corresponding expected value of the error. Note that even in this case the answer might be a "deterministic" choice of the sample $$S$$.

A final remark: The condition $$T^{-1}\int_0^T f(t) = 0$$ in the problem statement is not really necessary. If $$T^{-1}\int_0^T f(t) =: \bar{f} \neq 0$$ you can minimize $$|\bar{f} - n^{-1}\sum_{t \in S}f(t)|$$ instead and you will always obtain exactly the same result, since shifting everything by $$\bar{f}$$ does not make any difference.

• Yes sorry I was unclear, I meant that $f$ is differentiable with mean $0$ but otherwise arbitrary. Thanks for your answer. Feb 28, 2023 at 23:57

This seems like it may well be an unsolvable problem. The set of all functions on an interval with zero mean is infinite-dimensional, as is the set of all distributions on that interval.

If you remove the requirement that f be differentiable (I assume that's what you mean by "differential"), then in my understanding it's actually possible to prove that ALL distributions are in some sense "equally good". For suppose that for a function f1(t), one sample set S1 of n points gives a mean m1 and another sample set S2 gives a mean m2, with |m1| < |m2|. Then, construct another function f2(t) where the values at ONLY those 2n values of t are swapped. Now, S1 has mean m2 and S2 has mean m1, so now S2 is a "better" sample, and these functions are in effect "equally likely" to be your f because they have equal mean. It would take some more work to make this truly rigorous, as we're talking about two random samples from different distributions, rather than ONE sample each, but my intuition says it still holds.

Now, requiring differentiability (and hence smoothness) MAY make it possible to say more about a good sampling strategy, but this doesn't HAVE to be true. The most that can be said without some real heavy math (well beyond elementary statistic courses) is that for a uniform distribution, the sample mean approaches 0 as n gets very large.