function hybridhw; % INPUT % s .. number of seats % v .. vector with the votes for each party % % OUTPUT % e .. array with the number of seats for various methods % inputs s=input('give the number of seats : '); if s-fix(s)>0,error('---------->Give integer number of seats');end; len=input('give the number of parties: '); fprintf(' Put the parties in order of priority for ties.\n'); v=zeros(len,1); for j1=1:len, fprintf('give votes for party - %1.0f : ',j1); v(j1)=input(''); end; v=v.*(1+(len*1e-10:-1e-10:1e-10)'); % disturbance for handling ties suma=sum(v); p=s*v/suma; % fair share % Hamilton resids=sort(p-fix(p),'descend');tresh=resids(s-sum(fix(p)))-100*eps; eh=fix(p)+(p-fix(p)>tresh); % Hybrid Hamilton/Webster) resids=sort(p./(ceil(p)-1/2),'ascend');tresh=resids(sum(ceil(p))-s)+100*eps; em=ceil(p)-(p./(ceil(p)-1/2)=metro)'; return