% LMex030602_4th
% An exercise in finding definite integrals and propagation of error
% Page 197-198 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu, written 2001, revised 1/12/11
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% A random variable is described by the pdf fY(y)=2y 0<y<1. What is the
% standard deviation of 3Y+2?
% This problem will calculate the variance of y in a symbolic expression 
% and then calculate the variance of a linear equation involving y. The
% symbolic variance of the equation will then be converted to its numeric
% value using eval.
syms y
EY=int(y*2*y,0,1)
EY2=int(y^2*2*y,0,1)
VARY=EY2-EY^2
VAR3Yplus2=3^2*VARY
STD=(VAR3Yplus2)^(1/2)
% STD is a symbolic variable. It can be converted to a numeric variable
% using Matlab's eval function.
eval(STD)