Expected value and variance of a piecewise function with the integral

10.3k Views Asked by At

I have the following stepwise function: $$f(x) = \begin{cases} \frac{1}{3} & -1\le x \lt 0 \\ \frac{2}{3} & 0 \le x \le 1 \\ 0 & \text{otherwise} \end{cases} $$

I wonder how I can derive $E(X)$ and $Var(X)$ of a stepwise uniform function using the integral. If I draw it I would say the mean is at $x = 1/4$ (as then the area below the function equals $0.5$). But when I am integrating it I get $1/6$.

Can someone help me and show how I properly solve this question?

Thanks a lot!

2

There are 2 best solutions below

1
On

Here is a start:

$$\mu = E(X) = \int_{-1}^1 xf(x)\,dx = \int_{-1}^0 x(1/3)\,dx + \int_0^1 x(2/3)\,dx = \dots\,.$$ Find $E(X^2)$ similarly, and use $Var(X) = E(X^2) - \mu^2.$

0
On

Thank you already!

So, then

$$\mu=E[X]=\int_{-1}^0x(1/3)dx + \int_0^1x(2/3)dx = (0-{1\over6})+({1\over3}-0)={1\over6}$$

and

$$Var[X]=\int_{-1}^0x^2(1/3)dx + \int_0^1x^2(2/3)dx - \mu^2=(0+{1\over9})+({2\over9}-0)-({1\over6})^2={11\over36}$$

Is this correct?