TITLE: $g$ an indicator function that equals $\{x-\theta\}+\theta-1$
QUESTION [1 upvotes]: I have been trying to understand a proof in which this equality takes place:
$\theta \in [0,1]$
\begin{align}g
(x)=\{x\}-\begin{cases}
0, & \mbox{ if }(\{x\}<\theta)\\1, & \mbox{ if }(\{x\}\geqslant \theta)\end{cases}=\{x-\theta\}+\theta-1\end{align}
I just cannot see how to transform an indicator function into other kind of expression like the later one.
Question: 
How does the author deduces this equality?
Thanks in advance!

REPLY [2 votes]: Without loss of generality assume that $x\in[0,1)$, i.e. $\{x\}=x$.  
If $x-\theta\geq 0$, knowing $x-\theta<1$ we have: 
$$
\{x-\theta\}=x-\theta.
$$
If $x-\theta<0$, knowing $x-\theta\geq -1$, we have:
$$
\{x-\theta\}=x-\theta+1.
$$
Pluging this into $\{x-\theta\}+\theta-1$ yields the equality.
{"set_name": "stack_exchange", "score": 1, "question_id": 2890231}