function q=getrfree(ymat,pim,bet,gam) ;
% function to get the risk free price
                   % ymat is the vector of quadrature points
                   % pim is the transition matrix
                   % bet is beta
                   % gam is gamma

mrs=bet*exp(ymat*(-gam)) ;
                   % computes an nx1 matrix whose i element is
                   % beta*exp[(1-gamma)*y(i)]. So it is the value of the
                   % variable beta*exp[(1-gamma)*x(t+1)] if state i
                   % occured at time t+1

% the risk free price is E(t) mrs(t+1) which is sum(i) pim(j,i) mrs(i)
% if state j occured at time t.  So the next statement creates a vector
% whose j element is the risk free price at time t if state j occured at
% time t

q=pim*mrs ;
