deriving cdf of uniform distribution 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.
 A: 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$.
A: Everything up to $x > b$ is perfect.
But your reasoning in the final case is not quite correct, because the integral is taken over an interval that includes parts of the PDF that are nonzero.  In other words, the interval $(a,b)$ is a subset of the interval $(-\infty, x)$ if $x > b$.  Just because the density is zero when $x > b$, it doesn't mean that the integral from $(-\infty, x)$ is itself zero, because as we can see, there are points within the interval of integration for which the density is positive.
For example, if I say to you to calculate the integral of $g(x) = 1-x$ from $x = 0$ to $x = 1$, what would you write?  $$\int_{x=0}^1 1-x \, dx = \left[x - \frac{x^2}{2}\right]_{x=0}^1 = 1 - \frac{1}{2} = \frac{1}{2}.$$  Now if I give you the function $$h(x) = \begin{cases} g(x), & 0 \le x \le 1 \\ 0, & x > 1, \end{cases},$$ what would the integral of $h$ be from $x = 0$ to $x = 2$?  It's the same as the above, because the area under the curve of $h$ from $x = 1$ to $x = 2$ is zero, so you've not added any area, but the total area is not zero because you still had area from $x = 0$ to $x = 1$.
