I know that to genarete ramdom variables following exponential distribution just do: $$X=-\frac{1}{\lambda}ln(U)$$
where $U\sim U(0,1)$
Now, to find a distribution restricted to the interval $(a, b)$, I used the truncated distribution (Trucated distribution) coming in the following cumulative distribution $$H(t)=\frac{e^{-\lambda a}-e^{-\lambda t}}{e^{-\lambda b}-e^{-\lambda a}}$$
However I don't Know to find the inverse function $H^{-1}$. Also I don't know if this expression is correct. I thank
Try the random variable $$ X=x-\frac1\lambda\cdot\log(U+u), $$ for some suitable $(u,x)$. Unless I am mistaken, if $(u,x)$ solves $$ \mathrm e^{-\lambda x}=\mathrm e^{-\lambda a}-\mathrm e^{-\lambda b},\quad u=\mathrm e^{-\lambda(b-x)}, $$ then $X$ is uniform on $(a,b)$.
Edit: Note that if $$ H(t)=\frac{\mathrm e^{-\lambda a}-\mathrm e^{-\lambda t}}{\mathrm e^{-\lambda b}-\mathrm e^{-\lambda a}}, $$ then $$ t=-\frac1{\lambda}\cdot\log\left(H(t)\mathrm e^{-\lambda b}+(1-H(t))\mathrm e^{-\lambda a}\right). $$ In terms of $(u,x)$ introduced above, this reads $$ t=x-\frac1{\lambda}\cdot\log\left(1-H(t)+u\right). $$ Note finally that, if $U$ is uniform on $(0,1)$ then $X$ and $X'$ are identically distributed, where $X$ is defined above and $$ X'=x-\frac1\lambda\cdot\log(1-U+u), $$