# machine learning for a rule

I have data in the following form , where x is an integer and r is 0 or 1.

I know that

• if $x < C$, then $r = 1$,
• if $x\geq C$, then $r= 0$.

How can I automatically estimate the value of $C$? Can I have any guarantees on the convergence?

There must be an easy way to solve this, I just cannot find out!

-

If you have no idea to start with, you could start checking $1, 2, 4, \ldots 2^n$ until $r$ drops to zero. Then you can use the bisection method of root finding to find the actual value. Basically it takes the range that you know the transition is in, bisects it, and reduces the range appropriately. Say $f(32)=1$ and $f(64)=0$. Check $f(48)$. If it is $1$, your range is now $(48,64]$. If it is $0$, your range is now $(32,48]$. Keep going this way.