I come from a physics background, and as a result of one of my simulations, I get the following function:

On the x axis, the sampled points are of the form $m/n$ with $n \in [1,20]$ and $m \in {1,2,...,n-1}$. Basically just all the rational numbers less than $1$ with the maximum possible denominator equal to 20. I feel that I have seen a similar curve somewhere, but I can't remember. Is there any known discontinuous function that looks like this?
A table of values the function takes:
$$\begin{array}{c|c|c|} m & n & f(m,n) \\ \hline 1 & 2 & 1\\ \hline 1 & 3 & 2\\ \hline 2 & 3 & 1\\ \hline 1 & 4 & 3\\ \hline 2 & 4 & 1\\ \hline 3 & 4 & 1\\ \hline 1 & 5 & 4\\ \hline 2 & 5 & 2\\ \hline 3 & 5 & 3\\ \hline 4 & 5 & 1\\ \hline 1 & 6 & 5\\ \hline 2 & 6 & 2\\ \hline 3 & 6 & 1\\ \hline 4 & 6 & 1\\ \hline 5 & 6 & 1\\ \hline 1 & 7 & 6\\ \hline 2 & 7 & 3\\ \hline 3 & 7 & 2\\ \hline 4 & 7 & 5\\ \hline 5 & 7 & 4\\ \hline 6 & 7 & 1\\ \hline \end{array}$$
$f(m,n)$ is only a function of $m/n$ and not $m$ and $n$ separately. A pattern I have noticed is always $f(n-1,n)=1$, and $f(1,n)=n-1$. Other than these two cases, I have not been able to find any patterns.
Edit: I have found an analytical statement to evaluate this function. But its form looks somewhat complicated, so I find it difficult to believe that there can be closed-form expressions for it. The function (in a non-mathematician's language) is as follows:
For 2 coprime integers $m$ and $n$, and $x=m/n$, $f(x)$ = $n_{max}$ where $n_{max}$ is the maximum natural number $<n$, such that $\sin(j \pi x) \sin{ \pi(\text{Ceil}(nx) - (n-j)x)}>0$, for all $j=1,2,3...(n-1)$.
The Ceil(x) function returns the smallest integer more than x. This function can probably be simplified further (the sines can be removed to put a condition on the arguments), but because of the Ceil function, I could not make much progress. Another interesting feature is that the plot of $x$ vs $1/f(x)$ looks similar to Thomae's function:
https://en.wikipedia.org/wiki/Thomae%27s_function. 