Variance of a discontinuous PDF

iocal

Junior Member
Joined
Jun 30, 2013
Messages
68
Hi all,

I am looking for some help since I have not dealt with a discontinuous PDF before.
The exercise is asking me to find the mean and the variance of a distribution that has the pdf:

\(\displaystyle f(x) = \frac {1}{8}\ for\ x\in [0,2)\
and\ f(x)= \frac {x}{8}\ for\ x\in [2,4)\)

My first thought was to find the mean of each part separately and add them together. I get the right answer this way. It is 31/12.

But when I tried to find the variance of each part by using the formula \(\displaystyle \ \sigma^2 = E(X^2) - \mu^2\), for each different part and then add them together I do not arrive at the right answer, which by the way is 167/144. I Instead get 375/144.

Where have I gone wrong?
 
I'm not sure what you mean by "find the mean of each part separately". "Each part" is not a PDF, since it does not integrate to 1. But it is true that the "mean" of PDF, f(x), defined on [a, b], is \(\displaystyle \int_a^b xf(x)dx\) and, as you learned in Calculus, \(\displaystyle \int_a^b xf(x)dx= \int_a^c xf(x)dx+ \int_c^b xf(x)dx\).

That is, here, the mean is \(\displaystyle \int_0^4 xf(x)dx= \int_0^2 x(\frac{1}{8})dx+ \int_2^4 x(x/8)dx= \frac{1}{8}\int_0^2 xdx+ \frac{1}{8}\int_2^4 x^2 dx\)\(\displaystyle = \frac{1}{16}\left[ x^2\right]_0^2+ \frac{1}{24}\left[ x^3\right]_2^4= \frac{4}{16}+ \frac{64}{24}- \frac{8}{24}= \frac{1}{4}+ \frac{8}{3}- \frac{1}{3}\)\(\displaystyle = \frac{3}{12}+ \frac{32}{12}- \frac{4}{12}= \frac{31}{12}\) as you say.

And, yes, the variance is given by \(\displaystyle \int_a^b (x- \mu)^2 f(x)dx\). The difficulty you are having might be that you are trying to use the "mean" from each "part" in the integral over each part. As I said before, these are NOT two separate PDFs, they do NOT have two different means. THE mean is \(\displaystyle \frac{31}{12}\) and you need to use that:
\(\displaystyle \int_0^2 (x- 31/12)^2(1/8)dx+ \int_2^4 (x- 31/12)^2(x/8) dx\)
\(\displaystyle = \frac{1}{8}\int_0^2 (x^2- (31/6)x+ 961/144) dx+ \frac{1}{8}\int_2^4 (x^3- (31/6)x^2+ (961/144)x) dx\)
 
Last edited:
I'm not sure what you mean by "find the mean of each part separately". "Each part" is not a PDF, since it does not integrate to 1. But it is true that the "mean" of PDF, f(x), defined on [a, b], is \(\displaystyle \int_a^b xf(x)dx\) and, as you learned in Calculus, \(\displaystyle \int_a^b xf(x)dx= \int_a^c xf(x)dx+ \int_c^b xf(x)dx\).

That is, here, the mean is \(\displaystyle \int_0^4 xf(x)dx= \int_0^2 x(\frac{1}{8})dx+ \int_2^4 x(x/8)dx= \frac{1}{8}\int_0^2 xdx+ \frac{1}{8}\int_2^4 x^2 dx\)\(\displaystyle = \frac{1}{16}\left[ x^2\right]_0^2+ \frac{1}{24}\left[ x^3\right]_2^4= \frac{4}{16}+ \frac{64}{24}- \frac{8}{24}= \frac{1}{4}+ \frac{8}{3}- \frac{1}{3}\)\(\displaystyle = \frac{3}{12}+ \frac{32}{12}- \frac{4}{12}= \frac{31}{12}\) as you say.

And, yes, the variance is given by \(\displaystyle \int_a^b (x- \mu)^2 f(x)dx\). The difficulty you are having might be that you are trying to use the "mean" from each "part" in the integral over each part. As I said before, these are NOT two separate PDFs, they do NOT have two different means. THE mean is \(\displaystyle \frac{31}{12}\) and you need to use that:
\(\displaystyle \int_0^2 (x- 31/12)^2(1/8)dx+ \int_2^4 (x- 31/12)^2(x/8) dx\)
\(\displaystyle = \frac{1}{8}\int_0^2 (x^2- (31/6)x+ 961/144) dx+ \frac{1}{8}\int_2^4 (x^3- (31/6)x^2+ (961/144)x) dx\)

Thank you for the clarification. I got it right in the end.
I found it easier to use the other formula for the variance \(\displaystyle \ \sigma^2 = E(x^2)-\mu^2\)
Then taking expectations it becomes:

\(\displaystyle \displaystyle E(x^2)= \int_0^2 x^2 \frac{1}{8}\ dx +\int_2^4 x^3 \frac {1}{8} dx =\frac {47}{6}\)

Then the variance is simply given by\(\displaystyle \frac{47}{6}-(\frac {31}{12})^2 = 167/144\) exactly what we were looking for.
Thanks again.
 
Hi all,

I am looking for some help since I have not dealt with a discontinuous PDF before.
The exercise is asking me to find the mean and the variance of a distribution that has the pdf:

\(\displaystyle f(x) = \frac {1}{8}\ for\ x\in [0,2)\
and\ f(x)= \frac {x}{8}\ for\ x\in [2,4)\)

My first thought was to find the mean of each part separately and add them together. I get the right answer this way. It is 31/12.

But when I tried to find the variance of each part by using the formula \(\displaystyle \ \sigma^2 = E(X^2) - \mu^2\), for each different part and then add them together I do not arrive at the right answer, which by the way is 167/144. I Instead get 375/144.

Where have I gone wrong?
The way I interpret what you said you did was to find The mean of the first part of the pdf to be \(\displaystyle \mu_1 = 1\), representing 1/4 of the total area of the pdf. Then you found \(\displaystyle \mu_2 = 28/9\), for the remaining 3/4 of the distribution. The overall mean is the weighted sum

\(\displaystyle \displaystyle \mu = \frac{1}{4} \mu_1 + \frac{3}{4} \mu_2 = \frac{1}{4} + \frac{7}{3} = \frac{31}{12}\)

Now your problem is how to combine the two independent Variances. The correct way is to weight by the squares of the partial derivatives of the function. Thus

if........ \(\displaystyle f(x_1,x_2) = \alpha\ x_1 + \beta\ x_2 \),

then... \(\displaystyle \mathrm V[f] = \alpha^2\ \mathrm V[x_1] + \beta^2\ \mathrm V[x_2] \).

Applying that to the weighted sum you used to calculate \(\displaystyle \mu\),

........\(\displaystyle \displaystyle \mathrm V[x] = \frac{1}{16} \mathrm V_1 + \frac{9}{16}\mathrm V_2 \)

See if you can get the correct answer that way!
 
The way I interpret what you said you did was to find The mean of the first part of the pdf to be \(\displaystyle \mu_1 = 1\), representing 1/4 of the total area of the pdf. Then you found \(\displaystyle \mu_2 = 28/9\), for the remaining 3/4 of the distribution. The overall mean is the weighted sum

\(\displaystyle \displaystyle \mu = \frac{1}{4} \mu_1 + \frac{3}{4} \mu_2 = \frac{1}{4} + \frac{7}{3} = \frac{31}{12}\)

Now your problem is how to combine the two independent Variances. The correct way is to weight by the squares of the partial derivatives of the function. Thus

if........ \(\displaystyle f(x_1,x_2) = \alpha\ x_1 + \beta\ x_2 \),

then... \(\displaystyle \mathrm V[f] = \alpha^2\ \mathrm V[x_1] + \beta^2\ \mathrm V[x_2] \).

Applying that to the weighted sum you used to calculate \(\displaystyle \mu\),

........\(\displaystyle \displaystyle \mathrm V[x] = \frac{1}{16} \mathrm V_1 + \frac{9}{16}\mathrm V_2 \)

See if you can get the correct answer that way!


Hello! Your way seems much easier than what I have tried so far.
Well continuing from your last line then I get:

\(\displaystyle \displaystyle \frac {1}{8} \int_0^2 x^2\ dx = \frac {1}{3}\ and\ \frac{1}{8} \int_2^4 x^3\ dx = \frac {240}{32}\)

Then \(\displaystyle \displaystyle \mathrm V[x] = \frac {1}{16}(\frac{1}{3}-\frac{1}{16}) +\frac{9}{16}(\frac{240}{32}-\frac{49}{9}) = \frac{901}{768}\)

Which is not exactly equal to \(\displaystyle \ \frac{167}{144}\). Is that what you had in mind or have I got something wrong? I used the formula \(\displaystyle \sigma^2=E(x^2)-\mu^2\) to find each variance.
 
Last edited:
Hello! Your way seems much easier than what I have tried so far.
Well continuing from your last line then I get:

\(\displaystyle \displaystyle \frac {1}{8} \int_0^2 x^2\ dx = \frac {1}{3}\ and\ \frac{1}{8} \int_2^4 x^3\ dx = \frac {240}{32}\)

Then \(\displaystyle \displaystyle \mathrm V[x] = \frac {1}{16}(\frac{1}{3}-\frac{1}{16}) +\frac{9}{16}(\frac{240}{32}-\frac{49}{9}) = \frac{901}{768}\)

Which is not exactly equal to \(\displaystyle \ \frac{167}{144}\). Is that what you had in mind or have I got something wrong? I used the formula \(\displaystyle \sigma^2=E(x^2)-\mu^2\) to find each variance.
I am going to have to take some time to work this out,
1) I don't agree with your Variances, because the 1st and 2nd moments have to be normalized to the 0th moment.
2) There is a third component to the combined Variances, do to the separation of the means of the two portions.
 
I am going to have to take some time to work this out,
1) I don't agree with your Variances, because the 1st and 2nd moments have to be normalized to the 0th moment.
2) There is a third component to the combined Variances, do to the separation of the means of the two portions.
U have come to the conclusion that it is really easier to do the integrals of the complete pdf, rather than combining two separate portions of it. Let me recap.

\(\displaystyle \displaystyle f(x) = \begin {Bmatrix} 1/8 & \mathrm{if}\ 0\le x < 2 \\ x/8 & \mathrm{if}\ 2 \le x < 4 \\ 0 & \mathrm{otherwise} \end{Bmatrix}\)

The general moment (about 0) is

\(\displaystyle \displaystyle \nu_n = \int x^n\ f(x)\ dx = \frac{1}{8} \int_0^2x^n\ \mathrm d x + \frac{1}{8} \int_2^4x^{n+1}\ \mathrm d x \)

......\(\displaystyle \displaystyle = \dfrac{2^{n+1}}{8(n + 1)} + \dfrac{4^{n+2} - 2^{n+2}}{8(n+2)} \)

\(\displaystyle \displaystyle \nu_0 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{3}{4}\;\;\;= \;\;\;1\)

\(\displaystyle \displaystyle \nu_1 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{7}{3}\;\;\;= \;\;\;\frac{31}{12}\)

\(\displaystyle \displaystyle \nu_2 =\;\;\; \frac{1}{3}\;\;\; +\;\;\;\frac{15}{2}\;\;\;= \;\;\;\frac{47}{6}\)

Whereas the moments for the two pieces of \(\displaystyle f(x)\) DO add, the partial Variances do NOT. If you have computed two separate Variances, you may have to undo that calculation to get back to the second moments before you can combine them. At the very least you will have to add another term to the sum, giving the Variance for the separation of the two partial means. Consider \(\displaystyle \mu = \nu_1/\nu_0\).
1/4 of the statistical weight is centered at \(\displaystyle x = (1/4)/(1/4) = 1\), and
the remaining 3/4 is centered at \(\displaystyle x = (7/3)/(3/4) = 28/9\).
The overall mean is \(\displaystyle \mu = (31/12)/(1) = 31/12\).
The second moment (with respect to the mean is

....\(\displaystyle \displaystyle \nu_2(1,2) = \frac{1}{4} \left( \frac{31}{12} - 1 \right)^2 + \frac{3}{4} \left( \frac{28}{9} - \frac{31}{12} \right)^2
= \frac{1}{4} \left( \frac{19}{12}\right)^2 + \frac{3}{4} \left( \frac{19}{36}\right)^2
= \frac{1}{3}\left( \frac{19}{12}\right)^2 \)

Thus I can picture three components of Variuance.
\(\displaystyle V_1 = \frac{4}{3} - 1^2 = 1/3 \)
\(\displaystyle V_2 = 10 - (\frac{28}{9})^2 = 26/81 \)
\(\displaystyle V_3 = \frac{1}{3}\left( \frac{19}{12}\right)^2 - 0^2\)

Trying \(\displaystyle \displaystyle V = \frac{1}{4}V_1 + \frac{3}{4}V_2 + V_3 \)

.............\(\displaystyle \displaystyle = \frac{1}{12} + \frac{13}{54} + \frac{361}{432} = \frac{36 + 104 + 361}{432} = \frac{167}{144}\)

SURPRISE! That is the correct answer. Piece of cake.
 
U have come to the conclusion that it is really easier to do the integrals of the complete pdf, rather than combining two separate portions of it. Let me recap.

\(\displaystyle \displaystyle f(x) = \begin {Bmatrix} 1/8 & \mathrm{if}\ 0\le x < 2 \\ x/8 & \mathrm{if}\ 2 \le x < 4 \\ 0 & \mathrm{otherwise} \end{Bmatrix}\)

The general moment (about 0) is

\(\displaystyle \displaystyle \nu_n = \int x^n\ f(x)\ dx = \frac{1}{8} \int_0^2x^n\ \mathrm d x + \frac{1}{8} \int_2^4x^{n+1}\ \mathrm d x \)

......\(\displaystyle \displaystyle = \dfrac{2^{n+1}}{8(n + 1)} + \dfrac{4^{n+2} - 2^{n+2}}{8(n+2)} \)

\(\displaystyle \displaystyle \nu_0 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{3}{4}\;\;\;= \;\;\;1\)

\(\displaystyle \displaystyle \nu_1 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{7}{3}\;\;\;= \;\;\;\frac{31}{12}\)

\(\displaystyle \displaystyle \nu_2 =\;\;\; \frac{1}{3}\;\;\; +\;\;\;\frac{15}{2}\;\;\;= \;\;\;\frac{47}{6}\)

Whereas the moments for the two pieces of \(\displaystyle f(x)\) DO add, the partial Variances do NOT. If you have computed two separate Variances, you may have to undo that calculation to get back to the second moments before you can combine them. At the very least you will have to add another term to the sum, giving the Variance for the separation of the two partial means. Consider \(\displaystyle \mu = \nu_1/\nu_0\).
1/4 of the statistical weight is centered at \(\displaystyle x = (1/4)/(1/4) = 1\), and
the remaining 3/4 is centered at \(\displaystyle x = (7/3)/(3/4) = 28/9\).
The overall mean is \(\displaystyle \mu = (31/12)/(1) = 31/12\).
The second moment (with respect to the mean is

....\(\displaystyle \displaystyle \nu_2(1,2) = \frac{1}{4} \left( \frac{31}{12} - 1 \right)^2 + \frac{3}{4} \left( \frac{28}{9} - \frac{31}{12} \right)^2
= \frac{1}{4} \left( \frac{19}{12}\right)^2 + \frac{3}{4} \left( \frac{19}{36}\right)^2
= \frac{1}{3}\left( \frac{19}{12}\right)^2 \)

Thus I can picture three components of Variuance.
\(\displaystyle V_1 = \frac{4}{3} - 1^2 = 1/3 \)
\(\displaystyle V_2 = 10 - (\frac{28}{9})^2 = 26/81 \)
\(\displaystyle V_3 = \frac{1}{3}\left( \frac{19}{12}\right)^2 - 0^2\)

Trying \(\displaystyle \displaystyle V = \frac{1}{4}V_1 + \frac{3}{4}V_2 + V_3 \)

.............\(\displaystyle \displaystyle = \frac{1}{12} + \frac{13}{54} + \frac{361}{432} = \frac{36 + 104 + 361}{432} = \frac{167}{144}\)

SURPRISE! That is the correct answer. Piece of cake.

Thanks a bunch for doing all that. I greatly appreciate it. On that note though, I would prefer to do it the other way.
You have scared me a bit haha.
 
Thanks a bunch for doing all that. I greatly appreciate it. On that note though, I would prefer to do it the other way.
You have scared me a bit haha.
Remember this technique if you ever have "radius of gyration" problems in Physics.
 
Top