clear all; clf
format compact


for cond=1:3;

    if cond==1; retint=3; nitems = 10; c= 7.75; thresh=.78; slope=4.85; end;
    if cond==2; retint=4; nitems = 15; c= 8.63; thresh=.75; slope=5.61; end;;
    if cond==3; retint=5; nitems = 20; c= 8.98; thresh=.74; slope=6.42; end;;


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

    d=d*2+retint-2;

    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
