function [est,v]=importance(f,g,Ginv,u)
%runs a simulation on the function 'f" using importance density "g"(both character strings) and inverse c.d.f. "Ginverse"
 % outputs all estimators (should be averaged) and variance.
% IM  is the inverse cf of the importance distribution c.d.f. 
IM= eval(strcat(Ginv,'(u)'));   %=.47+.53*sqrt(U);
%IMdens is the density of the importance sampling distribution at IM
IMdens=eval(strcat(g,'(IM)'));       %2*(IM-.47)/(.53)^2;

FN=eval(strcat(f,'(IM)'));
est=FN./IMdens;       %  mean(est) prrovides the estimator
v=var(FN./IMdens)/length(IM);   % this is the variance of the estimator per simulation

