% The purpose of this code is to simulate theh Nicholson Bailey model for 
% host-parasitoid interaction

clear;
%set the initial data
N =68;
P = 10;

%set the number of iterates
M = 200;

%set the parameters
k = 1.05;
a = 0.005;
c = 3;


%store the initial data
n(1) = N;
p(1) = P;


%iterate
for j=2:M

%evaluate the functions 

Prob = exp(-a*P);
N_new = k*N*Prob;
P_new = c*N*(1-Prob);





%store the current values
n(j) = N_new;
p(j) = P_new;

%update
N = N_new;
P = P_new;
end

%make some plots
figure(1)
plot([1:M],n,'b',[1:M],p,'r',[1:M],n,'b*',[1:M],p,'r*')

figure(2)
plot(n,p,'*')

