clear; format compact; clf
c=8.54; wt=.91; wp=1-wt; nitems = 5; nlists=5;

dtim=zeros(1,25);
ccc=0;
for z=25:-1:1;
    dtim(z)=ccc; ;
    ccc=ccc+2.5;
end
eee=0;
for z=25:-1:1;
    eee=eee+1;
    for counter=5:5:250
        if eee>counter; dtim(z)=dtim(z)+2.5; end;
    end
end
dtim=dtim+120;

dpos=[5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1];

for n=1:nitems*nlists; dtim(n)=log(dtim(n)); end

for n=1:25; sumsim(n)=0.0; end

for n=1:25;
    for m=1:25;
        distance=wt*abs(dtim(n)-dtim(m))+wp*abs(dpos(n)-dpos(m));
        sumsim(n) = sumsim(n) + exp(-c*distance);
    end
    for out=1:25
        distance(out)=wt*abs(dtim(n)-dtim(out))+wp*abs(dpos(n)-dpos(out));
        sim(out)=(exp(-c*distance(out)));
        prob(n,out)=(sim(out)/sumsim(n));
    end
end


for norm=1:100;
    sumresp=sum(prob);
    for ui=1:25;
        prob(:,ui)=prob(:,ui)/sumresp(ui);
    end
    sumresp=sum(prob');
    for ui=1:25;
        prob(ui,:)=prob(ui,:)/sumresp(ui);
    end
end

for sd=1:5; inlist(sd,sd)=0; end
for inputlistpos=1:5
    for row=[0+inputlistpos 5+inputlistpos  10+inputlistpos  15+inputlistpos  20+inputlistpos ];
        for outputlistpos=1:5
            for col=[0+outputlistpos 5+outputlistpos 10+outputlistpos 15+outputlistpos 20+outputlistpos ];
                inlist(inputlistpos,outputlistpos)=inlist(inputlistpos,outputlistpos)+prob(row,col);
            end
        end
    end
end
inlist=inlist/5*100;

for sd=1:5; intrial(sd,sd)=0; end
for inputtrialpos=[0 5 10 15 20]
    for row=[1+inputtrialpos 2+inputtrialpos  3+inputtrialpos  4+inputtrialpos  5+inputtrialpos ];
        for outputtrialpos=[0 5 10 15 20]
            for col=[1+outputtrialpos 2+outputtrialpos 3+outputtrialpos 4+outputtrialpos 5+outputtrialpos];
                intrial(inputtrialpos/5+1,outputtrialpos/5+1)=intrial(inputtrialpos/5+1,outputtrialpos/5+1)+prob(row,col);
            end
        end
    end
end
intrial=intrial/5*100;

plot(inlist)
hold on
plot(intrial)

