clear all; clf
format compact


for cond=1:2;

    retint=16; nitems = 20; c= 19.97; thresh=.52; slope=11.6;

    d=[20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];

    d=d-1+retint;

    for n=1:nitems; d(n)=log(d(n)); end

    for itemnum=1:nitems
        dd=0;
        for m=1:nitems
            dd = dd+ exp(-c*(abs(d(itemnum)-d(m))));
        end
        for n=1:nitems
            prob(n,itemnum)=(exp( -c*(abs(d(itemnum)-d(n)))))/dd;
        end
    end

    for k=1:nitems+0; for j=1:nitems;
            prob(k,j)=1/(1+exp(-slope*(prob(k,j)-thresh)));
        end; end

    serpos=sum(prob');
    for n=1:nitems; serpos(n)=min(1,serpos(n)); end

    plot(serpos)

    axis([1 nitems 0 1.2])
    hold on
end
