I have a set of data consisting of the averages of a function $g(r)$ at regular intervals; i.e. my first datapoint is the average of the function from $0$ to $\Delta r$, the second point is the average from $\Delta r$ to $2\Delta r$ and so on.
In the end I want to decompose the function (that gives rise to these averages) in a certain basis. The easy way is to just treat the average points as points of the function and then either use a least squares fit or the normal "inner product-trick" to get the coefficients in this basis.
But I need to get closer to the underlying function. This of course means using some assumptions, since all I know is the averages, but demanding continuity of the function and of its derivatives (to one or more degrees) should do the trick.
I've tried some iterative methods, for example for 3rd degree polynomials: I divide the function into intervals of $\Delta r$ and use a 3rd degree polynomial on each interval. Then I start at the left and find the coefficients of the polynomial by using that the average should equal the data point and that the function and its first two derivatives should be continuous (between the intervals). The idea is then to use the resulting function with one of my methods (least squares, inner product) to find the decomposition.
However this iterative method gives a severely oscillating function. Say the function in the first interval overshoots a little bit, then the next has to undershoot and from there on it gets worse and worse, ending in the worst case with a function oscillating wildly around the data points (although it does satisfy the demands), and so far never ending with a satisfying function.
There must be a better way of doing this, either a completely different way of fitting/decomposing to averages of data points or another way of making my functions between intervals as described above. Both theoretic solutions and software solutions (matlab/mathematica functions etc) would be welcome. Any ideas?
EDIT: Here is a plot of the data: