Fit Quantized Piecewise Constant Function to Another Piecewise Constant Function

195 Views Asked by At

I have a situation where I have a function $$f(x) : [r_1,r_2]\in\mathbb{R} \rightarrow [r_3,r_4]\in\mathbb{R}$$ and I need to fit a function $$g(x) : [r_1,r_2]\in\mathbb{R} \rightarrow [z_1,z_2]\in\mathbb{Z}$$ onto it. That is, I have a continuous function, and I need to fit a quantized (equally spaced piecewise constant) function onto it. As a further constraint, $g$ must have at most $n$ splits.

The closest thing I could find is called regression trees (based on this answer), but it's not clear to me that quantizing the output of that would produce something good (and it's built to regress on points, not functions).

What should I look into?

1

There are 1 best solutions below

0
On

It really matters in what sense you want the piecewise constant function to be "close" to the continuous function. The "regression tree" you mentioned looks like it uses the same concept I am going to suggest: $L^2$ closeness, aka, Least Squares. As you mentioned it is designed for points but we can make sense of minimizing the squared difference for continuous functions.

If $[a, b]$ is one of your intervals over which you want to find the closest constant value you can minimize: $$\int_a^b (f(x) - \alpha)^2 dx$$ At the minimum, $\frac{d}{d\alpha} \int_a^b (f(x) - \alpha)^2 dx = -2\int_a^b (f(x) - \alpha) dx = 0$ so the minimum occurs at: $$\alpha_* = \frac{\int_a^b f(x) dx}{b - a}$$ In other words, the average of $f(x)$ over the interval.

Now it seems that you might want to find the best integer for the constant value of the curve. In that case, you can numerically minimize the above integral over integers. It may even be true that the best integer will be either the ceiling or floor of $\alpha_*$ above.