# Finding the Expected Value and Variance

The distribution function of a random variable $$X$$ is given by

$$P (X \leq x)$$ = $$\begin{cases} 0 & \text{if x<0}, \\ x^{k} & \text{if 0 \leq x \leq 1, \,\,\,\,\,\, k\geq1}, \\ 1 & \text{if x > 1}. \end{cases}$$

Determine the mean and variance of $$X$$.

Workings:

I am aware that I must start by calculating $$\sum_{-\infty}^{\infty} x \,\cdot p_X(x)$$, but because this is a continuous distribution, I will instead have to calculate $$\int_{-\infty}^{\infty} x \, \cdot p_X(x) \,dx$$. However, once I integrate it, I am confused as to what further steps as to which I am meant to take given that I get infinity as the expected value. Could someone please tell me if it is possible for the expected value to be infinite and if I have made a mistake in my workings? Thank you.

\begin{align} \text{E(X)} & = \int_{-\infty}^{\infty} x \, \cdot p_X(x) \,dx \\ & = \int_{-\infty}^{0} x \, \cdot 0 \,dx \: + \int_{0}^{1} x \, \cdot x^{k} \,dx \: + \int_{1}^{\infty} x \,dx \\ & = C + \bigg{[}\frac{x^{k+2}}{k+2}\bigg{]}_{0}^{1} + \bigg{[}\frac{x^{2}}{2}\bigg{]}_{1}^{\infty} \end{align}

• How did you find the PDF? You should take the derivative of the CDF. – drhab Feb 25 at 15:55

You are using the CDF in your integral, and you should instead use the PDF, which is the derivative $$p_X(x) = \begin{cases}0 & x \le 0 \\ k x^{k-1} & 0 \le x \le 1 \\ 0 & x > 1\end{cases}$$

• Thank you, I did not realise that I took the cdf as the pdf. – Garen Feb 26 at 10:25

No reason to compute the PDF here. If $$X$$ is a nonnegative random variable (w.p.1) which it is in this case, you can calculate:

$$\mathbb{E}[X] = \int_0^\infty \mathbb{P}(X \geq x)\mathrm{d}x =\int_0^\infty (1- F_X(x)\mathrm{d}x = \int_0^1 1-x^k \mathrm{d}x + \int_1^\infty 1-1\mathrm{dx} = \int_0^1 (1-x^k)\mathrm{d}x$$

For the variance, we just need to compute: $$\mathbb{E}[X^2] = \int_0^\infty \mathbb{P}(X^2 \geq x)\mathrm{d}x = \int_0^\infty \mathbb{P}(X \geq \sqrt{x} \text{ or } X \leq -\sqrt{x} )$$ Because $$X$$ is nonnegative, we have: $$\mathbb{E}[X^2] = \int_0^\infty \mathbb{P}(X \geq \sqrt{x})\mathrm{d} x = \int_0^\infty (1- F_X(\sqrt x))\mathrm{d}x = \int_0^1 1- x^{k/2} \mathrm{d}x$$

Once you have this the variance is: $$\mathbb{E}[X^2] - \mathbb{E}[X]^2$$

To prove the formula, let $$X$$ be a nonnegative random variable with density/PDF $$f_X$$. Note that: $$\mathbb{P}(X \geq x) = \int_x^\infty f_X(y) \mathrm{d}y$$ then: $$\int_0^\infty \mathbb{P}(X \geq x) \mathrm{d}x = \int_0^\infty \int_x^\infty f_X(y) \mathrm{d}y\mathrm{d}x$$ This is a double integral over the set in the plane given by $$\{(x,y) \in \mathbb{R}^2 : x > 0 , y>x\}$$ (i.e. an infinite triangle) of the function $$g(x,y) = f_X(y)$$ (only a function of $$y$$).

We can use Fubini's theorem (or more technically, Tonelli's theorem if you wish) to switch the order of integration and integrate with respect to $$x$$ first and $$y$$ second. This then becomes: $$\int_0^\infty \int_x^\infty f_X(y) \mathrm{d}y\mathrm{d}x = \int_0^\infty\int_0^y f_X(y)\mathrm{d}x\mathrm{d}y = \int_0^\infty yf_X(y) \mathrm{d}y$$ which is the formula for $$\mathbb{E}[X]$$.

This formula holds in more generality, for example for discrete RVs and continuous RVs that don't have densities.

• can you please explain why $\mathbb{E}[X] = \int_0^\infty \mathbb{P}(X \geq x)\mathrm{d}x$ ? – Rhino Feb 26 at 12:01
• @Rhino sure - I will edit and add to the post. – rubikscube09 Feb 26 at 14:19

You are integrating the distribution function and not the probability density

https://en.wikipedia.org/wiki/Probability_density_function

The two are related because the distribution function gives you the probability that $$X$$ is in $$]-\infty,x]$$ and the integral of the probability density between $$a$$ and $$b$$ gives you the probability of finding $$X$$ in $$[a,b]$$, so the distribution function $$P(X\le x)$$ is related to the probability density $$p_X(x)$$ by the relation

$$P(X\le x)=\int_{-\infty}^xp_X(t)dt$$

$$\int_{-\infty}^{0} x \, \cdot 0 \,dx+\ldots \\ =C+\ldots$$

A side note to this part: If you have a definite integral you don´t have the constant C as a part of the result.

$$\int_{a}^b f(x) \ dx=F(b)-F(a)$$

That means in the interval $$(-\infty, 0)$$ your integral is $$\int_{-\infty}^0 x\cdot 0 \ dx=0\cdot \int_{-\infty}^0 x \ dx=0\cdot \left[ \frac12\cdot x^2 \right]_{-\infty}^0=0-0=0$$

The last equality holds since one factor is zero:

$$"\textrm{If at least one factor of a product is zero, then the entire product is zero.}"$$

Although this can be solved by direct integration, it would be easier if we notice that $$X$$ follows a $$\text{Beta}(k,1)$$ distribution:

$$f_X(x)=kx^{k-1}\propto x^{k-1}$$

We can directly see that $$\mathbb E(X)=\frac{k}{k+1},\:\text{Var}(X)=\frac{k}{(k+1)^2(k+2)}$$

By the way it isn't uncommon for the expected value to be undefined (see Cauchy distribution), but in this case it is well defined.