% A Lotka-Volterra system with 2 species and 3 reactions % Stoichiometry matrix S = [1 -1 0; 0 1 -1 ]; % Initial condition M = [50; 100]; % Hazard function h = @(x, c) c.* [x(1); x(1)*x(2); x(2)]; % Stochastic rate constants c = [1 0.005 0.6]'; % Time span, from 0 to 30, in 100 steps tspan = linspace(0, 30, 101); figure; %[t, x] = gillespie(S, M, h, c, tspan); %[t, x] = Poisson_timestep(S, M, h, c, tspan); [t, x] = CLE(S, M, h, c, tspan); % Plot the realization plot(t, x); xlabel('Time'); ylabel('Number of individuals') legend('Prey', 'Predator', 'Location', 'NorthWest'); % Print the end state fprintf('End state: %d prey, %d predators \n', x(1,end), x(2,end));