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  σ2=E(X2)μ2\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 abxf(x)dx\displaystyle \int_a^b xf(x)dx and, as you learned in Calculus, abxf(x)dx=acxf(x)dx+cbxf(x)dx\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 04xf(x)dx=02x(18)dx+24x(x/8)dx=1802xdx+1824x2dx\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=116[x2]02+124[x3]24=416+6424824=14+8313\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}=312+3212412=3112\displaystyle = \frac{3}{12}+ \frac{32}{12}- \frac{4}{12}= \frac{31}{12} as you say.

And, yes, the variance is given by ab(xμ)2f(x)dx\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 3112\displaystyle \frac{31}{12} and you need to use that:
02(x31/12)2(1/8)dx+24(x31/12)2(x/8)dx\displaystyle \int_0^2 (x- 31/12)^2(1/8)dx+ \int_2^4 (x- 31/12)^2(x/8) dx
=1802(x2(31/6)x+961/144)dx+1824(x3(31/6)x2+(961/144)x)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 abxf(x)dx\displaystyle \int_a^b xf(x)dx and, as you learned in Calculus, abxf(x)dx=acxf(x)dx+cbxf(x)dx\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 04xf(x)dx=02x(18)dx+24x(x/8)dx=1802xdx+1824x2dx\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=116[x2]02+124[x3]24=416+6424824=14+8313\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}=312+3212412=3112\displaystyle = \frac{3}{12}+ \frac{32}{12}- \frac{4}{12}= \frac{31}{12} as you say.

And, yes, the variance is given by ab(xμ)2f(x)dx\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 3112\displaystyle \frac{31}{12} and you need to use that:
02(x31/12)2(1/8)dx+24(x31/12)2(x/8)dx\displaystyle \int_0^2 (x- 31/12)^2(1/8)dx+ \int_2^4 (x- 31/12)^2(x/8) dx
=1802(x2(31/6)x+961/144)dx+1824(x3(31/6)x2+(961/144)x)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  σ2=E(x2)μ2\displaystyle \ \sigma^2 = E(x^2)-\mu^2
Then taking expectations it becomes:

E(x2)=02x218 dx+24x318dx=476\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 by476(3112)2=167/144\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  σ2=E(X2)μ2\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 μ1=1\displaystyle \mu_1 = 1, representing 1/4 of the total area of the pdf. Then you found μ2=28/9\displaystyle \mu_2 = 28/9, for the remaining 3/4 of the distribution. The overall mean is the weighted sum

μ=14μ1+34μ2=14+73=3112\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........ f(x1,x2)=α x1+β x2\displaystyle f(x_1,x_2) = \alpha\ x_1 + \beta\ x_2 ,

then... V[f]=α2 V[x1]+β2 V[x2]\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,

........V[x]=116V1+916V2\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 μ1=1\displaystyle \mu_1 = 1, representing 1/4 of the total area of the pdf. Then you found μ2=28/9\displaystyle \mu_2 = 28/9, for the remaining 3/4 of the distribution. The overall mean is the weighted sum

μ=14μ1+34μ2=14+73=3112\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........ f(x1,x2)=α x1+β x2\displaystyle f(x_1,x_2) = \alpha\ x_1 + \beta\ x_2 ,

then... V[f]=α2 V[x1]+β2 V[x2]\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,

........V[x]=116V1+916V2\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:

1802x2 dx=13 and 1824x3 dx=24032\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 V[x]=116(13116)+916(24032499)=901768\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  167144\displaystyle \ \frac{167}{144}. Is that what you had in mind or have I got something wrong? I used the formula σ2=E(x2)μ2\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:

1802x2 dx=13 and 1824x3 dx=24032\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 V[x]=116(13116)+916(24032499)=901768\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  167144\displaystyle \ \frac{167}{144}. Is that what you had in mind or have I got something wrong? I used the formula σ2=E(x2)μ2\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.

f(x)={1/8if 0x<2x/8if 2x<40otherwise}\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

νn=xn f(x) dx=1802xn dx+1824xn+1 dx\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

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

ν0=      14      +      34      =      1\displaystyle \displaystyle \nu_0 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{3}{4}\;\;\;= \;\;\;1

ν1=      14      +      73      =      3112\displaystyle \displaystyle \nu_1 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{7}{3}\;\;\;= \;\;\;\frac{31}{12}

ν2=      13      +      152      =      476\displaystyle \displaystyle \nu_2 =\;\;\; \frac{1}{3}\;\;\; +\;\;\;\frac{15}{2}\;\;\;= \;\;\;\frac{47}{6}

Whereas the moments for the two pieces of f(x)\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 μ=ν1/ν0\displaystyle \mu = \nu_1/\nu_0.
1/4 of the statistical weight is centered at x=(1/4)/(1/4)=1\displaystyle x = (1/4)/(1/4) = 1, and
the remaining 3/4 is centered at x=(7/3)/(3/4)=28/9\displaystyle x = (7/3)/(3/4) = 28/9.
The overall mean is μ=(31/12)/(1)=31/12\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.
V1=4312=1/3\displaystyle V_1 = \frac{4}{3} - 1^2 = 1/3
V2=10(289)2=26/81\displaystyle V_2 = 10 - (\frac{28}{9})^2 = 26/81
V3=13(1912)202\displaystyle V_3 = \frac{1}{3}\left( \frac{19}{12}\right)^2 - 0^2

Trying V=14V1+34V2+V3\displaystyle \displaystyle V = \frac{1}{4}V_1 + \frac{3}{4}V_2 + V_3

.............=112+1354+361432=36+104+361432=167144\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.

f(x)={1/8if 0x<2x/8if 2x<40otherwise}\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

νn=xn f(x) dx=1802xn dx+1824xn+1 dx\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

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

ν0=      14      +      34      =      1\displaystyle \displaystyle \nu_0 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{3}{4}\;\;\;= \;\;\;1

ν1=      14      +      73      =      3112\displaystyle \displaystyle \nu_1 =\;\;\; \frac{1}{4}\;\;\; +\;\;\;\frac{7}{3}\;\;\;= \;\;\;\frac{31}{12}

ν2=      13      +      152      =      476\displaystyle \displaystyle \nu_2 =\;\;\; \frac{1}{3}\;\;\; +\;\;\;\frac{15}{2}\;\;\;= \;\;\;\frac{47}{6}

Whereas the moments for the two pieces of f(x)\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 μ=ν1/ν0\displaystyle \mu = \nu_1/\nu_0.
1/4 of the statistical weight is centered at x=(1/4)/(1/4)=1\displaystyle x = (1/4)/(1/4) = 1, and
the remaining 3/4 is centered at x=(7/3)/(3/4)=28/9\displaystyle x = (7/3)/(3/4) = 28/9.
The overall mean is μ=(31/12)/(1)=31/12\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.
V1=4312=1/3\displaystyle V_1 = \frac{4}{3} - 1^2 = 1/3
V2=10(289)2=26/81\displaystyle V_2 = 10 - (\frac{28}{9})^2 = 26/81
V3=13(1912)202\displaystyle V_3 = \frac{1}{3}\left( \frac{19}{12}\right)^2 - 0^2

Trying V=14V1+34V2+V3\displaystyle \displaystyle V = \frac{1}{4}V_1 + \frac{3}{4}V_2 + V_3

.............=112+1354+361432=36+104+361432=167144\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