# Homework Help: Mean and variance of a probability density

1. Oct 11, 2015

### toothpaste666

1. The problem statement, all variables and given/known data
find μ and σ^2 for the following probability density
f(x) = x for 0<x<1
f(x) = 2-x for 1 <= x < 2
f(x) = 0 elsewhere

2. Relevant equations
μ = ∫xf(x)dx

σ^2 = ∫x^2 f(x)dx - μ^2

3. The attempt at a solution
first we find the mean. we split up the integral into sums of different integrals
since f(x) = 0 from -∞ to 0 and from 2 to ∞ we have
μ = ∫(0to1)x^2dx + ∫(1to2)x(2-x)dx
= ∫x^2dx + ∫2xdx - ∫x^2dx
where the first integral is from 0 to 1 and the others are from 1 to 2
= (1/3)x^3|(0to1) + x^2|(1to2) - (1/3)x^3|(1to2)
= 1/3 + (4-1) - (8/3-1/3) = 1/3 + 3 -7/3 = 3-6/3 = 3-2 = 1

so the mean is 1. now to find the variance
σ^2 = ∫x^3dx + ∫x^2(2-x)dx - 1^2
= ∫x^3dx + ∫2x^2dx - ∫x^3dx - 1
= (1/4)x^4|(0to1) + (2/3)x^3|(1to2) - (1/4)x^4|(1to2) - 1
= 1/4 + (16/3-2/3) - (16/4-1/4) - 1
= 1/4 + 14/3 - 15/4 - 1
= 1.667

am i doing this correctly?

2. Oct 11, 2015

### Ray Vickson

No. Check your arithmetic for the last line.

3. Oct 11, 2015

### toothpaste666

oops. It would be .1667

4. Oct 11, 2015

### Ray Vickson

No, actually it would be 1/6 exactly.