**Given**: #p(x)=k-x+xe^(-x^2) # for # x in [0,4]#

**Required**: Mean and Standard Deviation

**Solution Strategy**:

1) Normalize #p(x)#, i.e. determine the #k: P(x)=int_0^4 p(x) dx =1#

2) Calculate the mean, #mu = int_0^4 xp(x) dx #

3) Calculate the standard deviation, #sigma=int_0^4 (x-mu)^2p(x)dx#

1) #P(x)=int_0^4 [k-x+xe^(-x^2)]dx =1# Apply linearity and write

# 1 = int_0^4 kdx -int_0^4xdx+int_0^4xe^(-x^2)dx #

# 1 = kx -x^2/2+int_0^4xe^(-x^2)dx # Let's deal with the 3rd integral

#I= int_0^4xe^(-x^2)dx, " let " u = -x^2#

#I= -1/2int e^udu = -1/2 e^u# Undo substitution

#I= -1/2 [e^(-x^2)]_0^4 = 1/2-1/(2e^16)=(e^16-1)/(2e^16) -> 1/2#

#1 = 4K-8+1/2 => K=17/8#

Check: #17/2-16/2+1/2=1#

Thus #p(x)=17/8-x+xe^(-x^2) #

2) Mean: #mu= int_0^4 x[17/8-x+xe^(-x^2)]dx #

#mu=int_0^4 17/8xdx-int_0^4x^2dx+color(red)[int_0^4x^2e^(-x^2)dx] #

# = {17/16x^2-x^3/3 +color(red) [sqrt(pi)("erf"(x))/4-x/(2e^(x^2)]}}_0^4#

# ~~ 17/16*16-64/3+color(red).443~~ -3.89#

3) #sigma^2= int_0^4 (x-3.89)^2 [17/2-x+xe^(-x^2)]dx#

# ~~27.23134392285682 #

#sigma = sqrt(27.23134392285682)~~ 5.2#