Help with this probability density function 
(a) Verify that$ f $is a PDF. That is,  check that $f(x)$ is always non-negative and that the area under $f(x)$ is $1$. My understanding is that if $a < x < b $then it is $1/b-a$ so the area would have to be non negative, the graph would look somewhat like this

$a$ being $20$ and $b$ being $40$. $1/20 = .05$ which is non negative but I am not sure how to prove it is $1$?
(b) Find the $CDF$ of $X$, $F(y)$, for all $y$.
Finding the $PDF$ first,
| x  | P(x)|
| ---| --- |
| 20 | .1  |
| 21 | .1  |
| 22 | .1  |
And so on
So $CDF$ would be
| x       | F(x)|
| ---     | --- |
| x<20    | .1  |
| 20<=x<21| .2  |
| 21<=x<22| .3  |
and so on
(c) Find $P(30<X<50)$.
Since $(20<=X<40)$ is $1/20$ would $P(30<X<50)$ just be $1/30$?
(d)Find expected value of X
$.1*20+.1*21....+.1*40$ (I have not calculated it yet but I believe this is the correct form)
It also asks to find standard deviation and variance, but as long as I am correct thus far I do not need help figuring it out. Thank you in advance!
 A: All of your calculations are for if f is discrete, but here f is continuous.
(a) To show that f(x) is a pdf, you have to verify that the area under it is 1. You can do it like this: $\int_{20}^{40}\frac{1}{20}dx=\frac 1 {20}[x]_{20}^{40}=\frac 1 {20}(40-20)=1$ Since the area under the pdf integrates to 1, it is a valid pdf. Or you can observe that the pdf is a rectangle that has height y=1/20 for 20<x<40 and is flat y=0 when x is not in that range. So the pdf is given by the area of the rectangle, 20*1/20=1. Your picture is right, now you need to multiply b-a by 1/(b-a).
(b) The cdf F(y) is the probability that X is less than y, aka P(X<y). For a uniform distribution, it is given by
$$F(y)=\begin{cases}0&y<a\\
\frac{y-a}{b-a}&a\le y<b\\1&y\ge b\end{cases}$$
Here we have
$$F(y)=\begin{cases}0&y<20\\
\frac{y-20}{40-20}&20\le y<40\\1&y\ge40\end{cases}$$
This is a flat line at 0 when y<20, a line with constant slope $\frac 1{20}$ when 20<y<40, and then a flat line at 1 when y>40.
(c) $P(30<X<50)=P(30<X<40)+\underbrace{P(40<X<50)}_{=0}=(40-30)*1/20=\frac 1 2$
where the second term is 0 because X has 0 density above 40.
(d) The expected value or mean of a continuous uniform distribution is $\frac{a+b}{2}=\frac{20+40}{2}=30$. It is the tick that is between the two ends.
