Perform one step of Omurtag-Sirovich model
function [xnew,evp,evn]=OmurtagSirovich(x,par,evp,evn)
Inputs:
- x: Nx1 array of states of traders each x(k) is in (-1,1)
- evp: number of buying events over previous nT time steps
- evn: number of selling events over previous nT time steps
- par: structure containing system parameters
- xnew: Nx1 array, new states of agents
- evp: updated number of buying events over previous nT time steps
- evn: updated number of selling events over previous nT time steps (negative)
Contents
function [xnew,evp,evn]=OmurtagSirovich(x,par,evp,evn)
[N,nvec]=size(x); oN=ones(N,1); xnew=x; Rp=mean(evp,1)/par.tstep; Rn=mean(evn,1)/par.tstep;
modify state of agents according to amount of information
pnews=poissrnd(par.tstep*(par.nup*(1+par.g.*Rp(oN,:))),N,nvec); nnews=poissrnd(par.tstep*(par.nun*(1+par.g.*abs(Rn(oN,:)))),N,nvec); forget=exp(-par.gamma*par.tstep);
update
xnew=xnew*forget+pnews.*par.epsplus(oN,:)-nnews.*par.epsminus(oN,:);
count firing events
xf=floor(xnew); xp=xnew>0; xc=ceil(xnew); xn=xnew<=0; evp=[evp(2:end,:);sum(xf.*xp,1)/N]; evn=[evn(2:end,:);sum(xn.*xc,1)/N];
reset x that have fired to 0
xnew(abs(xnew)>1)=0;
end