function Rx=Posterior(nmax, t, pN, A, komb) % Rx=Posterior(nmax, t, pN, A, komb) % % Rx(n+1, x+1) posterior probability of x=0:nmax-n remaining items given % that t time units have been spent and n=0:nmax prey items taken. % % nmax is maximum number of prey in a patch, and pN is the frequency % distribution for prey densities. % % A is the searching efficiency of the forager. % % komb is 'x over n' and should be created using XoverN before running % this function. % % The function should work for any prey distribution, but this is not % formally proven. % % - Equation 1 from % % Olsson, O & Holmgren NMA. 1998. The survival-rate-maximizing policy for % Bayesian foragers: wait for good news. Behav.Ecol. 9: 345-353. % % See also XoverN % OO 2008-08-08 Rx=zeros(nmax+1); for n=0:nmax x=0:nmax-n; N=x+n; Non=komb(N+1, n+1)'; Rx(n+1, x+1)=pN(N+1).*Non.*exp(-A.*t.*x); %eq 1 in O&H 1998 end sRx=sum(Rx, 2); Rx=Rx./repmat(sRx, 1, nmax+1);