function [Z,Zgrad]=computeZstub(lambda)
%assume length(lambda)=4
n=length(lambda)-1;k=(n+1)/2;
Z=0;
Zgrad=zeros(size(lambda));
for a1=0:k,
    for a2=0:(k-a1),
        for a3=0:(k-a1-a2),
            a4=k-a1-a2-a3;
            logv1=a1*log(lambda(1))+gammaln(a1+3/2)-gammaln(a1+1);
            logv2=a2*log(lambda(2))+gammaln(a2+3/2)-gammaln(a2+1);
            logv3=a3*log(lambda(3))+gammaln(a3+3/2)-gammaln(a3+1);
            logv4=a4*log(lambda(4))+gammaln(a4+3/2)-gammaln(a4+1);
            Z=Z+exp(logv1+logv2+logv3+logv4);            
        end
    end
end