clear all; clf
format compact


for cond=1:3;

    if cond==1; c  =  10.4457;  thresh= 0.3965; slope=  16.0063; nitems=20;  retint=10; end;
    if cond==2; c = 9.4124 ;   thresh=0.3022;  slope= 21.1236; nitems=30; retint=15; end;;
    if cond==3; c = 12.0333;   thresh=0.3049; slope= 22.8339; nitems=40;  retint=20; end;;


    if cond==1; d=[20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];  end
    if cond==2; d=[30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];  end
    if cond==3; d=[40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];  end


    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
