I am a Software Engineer who, within ~the last decade has had very little contact with more-than-primary-school-levels of math. To my chagrin it seems that I forgot not just how to do many things, I also forgot how they are called, so looking them up on my own has become annoyingly difficult.
Apologies in advance for the likely gutted idiom.
Here is a value table of a function $f(x, y) \to z$ with $x \in ([0, 10] \subset \mathbb{N}), z \in ([0, x] \subset \mathbb{N})$, $y \in ([0, 10] \subset \mathbb{R})$: $$ \begin{matrix} \left.\mathrm{x}\middle\\\mathrm{y}\right. & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 \\ 2 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 2 & 2 & 2 \\ 3 & 0 & 0 & 0 & 1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 \\ 4 & 0 & 0 & 0 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \\ 5 & 0 & 0 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 & 5 \\ 6 & 0 & 0 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 5 & 6 \\ 7 & 0 & 0 & 1 & 1 & 2 & 2 & 3 & 4 & 5 & 6 & 7 \\ 8 & 0 & 0 & 1 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ 9 & 0 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 10 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \end{matrix} $$ The table is filled by this algorithm:
- fill in $z$ from right to left starting with $x$ and decrementing by 1 until 0
- expand $z$ from left to right such that no sequence of same $z$ is longer than the previous one, until the row is completely filled
(I do not care about the table, other than as a tool for verification, and within this question, visualisation.)
Now, "gut feeling" tells me there should be a "traditionally" defined function perfectly fitting this table, but I find that I can recall neither how to proceed with constructing one, nor the necessary vocabulary to properly describe the task.
I am pretty sure with the right words it should be easy to find step-by-step tutorials by search machine, but trying queries like "linear fitting" do not produce results that... well, to be fair, that I can identify as being useful. E.g. here is the first Google hit I got for that query. ... Well, somehow I have here no random variables and no errors, nor am I trying to "predict" or "forecast" or "explain" anything? I also cannot quite imagine, what "overfitting" would even mean in this context. Long story short: That does not seem to be the right place to look in.
... Through "intuition" I have approximated this function as $f'(x, y) = \lfloor x \times \frac{y}{10} \rceil_{half \ down}$, but that one behaves notably different: For lack of better words, the given value table "prefers" strictly lower $z$ whereas the approximation alternates between "preferring" and "avoiding" intervals within each row of $z$.
$f'$ value table for the same input values (differences in bold): $$ \begin{matrix} \left.\mathrm{x}\middle\\\mathrm{y}\right. & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 \\ 2 & 0 & 0 & 0 & \boldsymbol 1 & 1 & 1 & 1 & 1 & 2 & 2 & 2 \\ 3 & 0 & 0 & \boldsymbol 1 & 1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 \\ 4 & 0 & 0 & \boldsymbol 1 & 1 & \boldsymbol 2 & 2 & 2 & 3 & 3 & 4 & 4 \\ 5 & 0 & 0 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 & 5 \\ 6 & 0 & \boldsymbol 1 & 1 & \boldsymbol 2 & 2 & \boldsymbol 3 & \boldsymbol 4 & \boldsymbol 4 & \boldsymbol 5 & 5 & 6 \\ 7 & 0 & \boldsymbol 1 & 1 & \boldsymbol 2 & \boldsymbol 3 & \boldsymbol 3 & \boldsymbol 4 & \boldsymbol 5 & \boldsymbol 6 & 6 & 7 \\ 8 & 0 & \boldsymbol 1 & \boldsymbol 2 & \boldsymbol 2 & \boldsymbol 3 & \boldsymbol 4 & \boldsymbol 5 & \boldsymbol 6 & 6 & 7 & 8 \\ 9 & 0 & \boldsymbol 1 & \boldsymbol 2 & \boldsymbol 3 & \boldsymbol 4 & 4 & 5 & 6 & 7 & 8 & 9 \\ 10 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \end{matrix} $$ I tried to play a bit with the rounding mode, or flooring instead of rounding, but did not find any further improvement through guesswork alone. All other attempts diverged harder than $f'$.
Questions:
- How can I create a better fit, besides "wild guessing"?
- How can I know whether an inaccurate fit is "the best I can get"?
(E.g. if it just does not get any better than $f'$, how would I know that I should stop searching?) - What vocabulary is used to describe what I am trying to do here?
(Specifically if we regard the value tables as merely a visualisation tool and concentrate on the algorithmic vs. the analytic form of the function.)