function [o,v,b,V1]=optimal2(U,subset) % generates optimal linear combination of five estimators and outputs % average estimator and variance. % subset is set of possible indices e.g. [1 2 4 5] % how does this differ from optimal??? Y1=(.53/2)*(fn(.47+.53*U)+fn(1-.53*U)); Y2=.37*.5*(fn(.47+.37*U)+fn(.84-.37*U))+.16*.5*(fn(.84+.16*U)+fn(1-.16*U)); Y3=.37*fn(.47+.37*U)+.16*fn(1-.16*U); intg=2*(.53)^3+.53^2/2; Y4=intg+fn(U)-GG(U); Y5=importance('fn',U); X=[Y1' Y2' Y3' Y4' Y5']; X=X(:,subset); mean(X) V=cov(X); Z=ones(length(subset),1); V1=inv(V); b=V1*Z/(Z'*V1*Z); o=mean(X*b); v=1/(Z'*V1*Z); % the variance per uniform input.... so divide by n