[Math] deriving cdf of uniform distribution

probability

I have that the pdf for a uniform distribution is given by $$f(x) = \frac{1}{b-a}$$ if $a \leq x \leq b $ and $0$ otherwise.

I am trying to derive the cdf.

From definition I have that the cdf is given by $F(x) = \int_{-\infty}^x f(t) \ dt$

So I will split it up to 3 intervals:

If $x < a$ we have that $f(x) = 0$ so $F(x) = 0$ here.

If $ a \leq x \leq b $ we have that $$F(x) = \int_{a}^x f(t) \ dt = \frac{x-a}{b-a}$$

If $ x > b$ the pdf says that $f(x) = 0$ here, so surely the cdf would be $$F(x) = \int_{-\infty}^\infty 0 \ dt = 0 $$ but however it is equal to $1$.

What is wrong with my approach, and how would you usually derive these answers.

Best Answer

If $x>b$: $$ F(x)=\int_{-\infty}^af(t)\;dt+\int_a^b f(t)\;dt+\int_b^xf(t)\;dt $$ The first integral is $0$, the second $1$ and the third $0$.

Related Question