1function [MAP,Eapx] = psfit_hyperexp(E,n)
3x0 = rand(1,2*n); x0(1:n)=x0(1:n)/sum(x0(1:n));
12options=optimset(
'Display',
'off',
'LargeScale',
'off',
'MaxIter',MAXITER,
'MaxFunEvals',1e10, ...
13 'MaxSQPIter',500,
'TolCon',TOL,
'Algorithm',
'interior-point',
'OutputFcn', psfit_hyperexp_outfun);
14T0 = tic; % needed
for outfun
16%% optimization program
17[x, f]=fmincon(@objfun,x0,[],[],[],[],x0*0+EPSTOL,[],@nnlcon,options);
19MAP = {T,-T*ones(n,1)*alpha};
20 function [alpha,T] = topar(x)
22 T = diag(-1./(x((n+1):2*n)));
25 function [c,ceq] = nnlcon(x)
31 function f = objfun(x)
34 Eapx(j)=factorial(j)*alpha*(-inv(T)^j)*ones(n,1);
36 f = norm(log(E)-log(Eapx),1);