  X = 0:10;
  p = [0.002  0.001  0.002  0.005  0.02  ...
        0.04  0.17 0.38  0.25  0.12  0.01];
  EX = X * p'               %(a) EX = 7.1600 
  VarX = (X-EX).^2 * p'     %(b) VarX = 1.5684 
  EX4 = X.^4 * p'           %(c) EX4 = 3.0746e+003 
  ps = [0 cumsum(p)];
  Fx = @(x)   ps( min(max( floor(x)+2, 1),12) ); %handle
  Fx(3.45)                  %(d) ans = 0.0100 
  sum(p(X < 4))           %(e) ans = 0.0100 
  sum(p(X > 2 & X <= 3))     %(f) ans = 0.0050 

  
  xx = -1:0.01:12;
  yy = Fx(xx);
  plot(xx, yy, 'k-')