%MCASQ2103
scores=[680
685
685
700
700
705
705
715
730
730
735
740
745
750
755
780
780
785
800
800];
% bootstrap the median and quartiles
trials=10000
modescore=zeros(1,trials);    % initialize vectors
medianscore=zeros(1,trials);
meanscore=zeros(1,trials);
lqscore=zeros(1,trials);
uqscore=zeros(1,trials);
bootsize=20;
for i=1:trials
    bs=sort(scores(ceil(rand(bootsize,1)*20))); % generate a single random draw of size 1001
    modescore(i)=mode(bs);
    medianscore(i)=median(bs);
    meanscore(i)=mean(bs);
    lqscore(i)=(bs(5)+bs(6))/2;
    uqscore(i)=(bs(15)+bs(16))/2;
end
hist(modescore,20),title('Mode'),figure(gcf),pause
hist(medianscore,20),title('Median'),figure(gcf),pause
hist(meanscore,20),title('Mean'),figure(gcf),pause

hist(lqscore,20),title('Lower Quartile'),figure(gcf),pause
hist(uqscore,20),title('Upper Quartile'),figure(gcf),pause

[sortmode,i]=sort(modescore);
lower95mode=sortmode(floor(.025*trials));
upper95mode=sortmode(ceil(.975*trials));
meanmode=mean(modescore);
disp([lower95mode meanmode upper95mode]);
%
[sortmedian,i]=sort(medianscore);
lower95median=sortmedian(floor(.025*trials));
upper95median=sortmedian(ceil(.975*trials));
meanmedian=mean(medianscore);
disp([lower95median meanmedian upper95median]);
%
[sortmean,i]=sort(meanscore);
lower95mean=sortmean(floor(.025*trials));
upper95mean=sortmean(ceil(.975*trials));
meanmean=mean(meanscore);
disp([lower95mode meanmode upper95mode]);
%
[sortlq,i]=sort(lqscore);
lower95lq=sortlq(floor(.025*trials));
upper95lq=sortlq(ceil(.975*trials));
meanlq=mean(lqscore);
disp('Lower quartile')
disp([lower95lq meanlq upper95lq]);
%
disp('Upper quartile')
[sortuq,i]=sort(uqscore);
lower95uq=sortuq(floor(.025*trials));
upper95uq=sortuq(ceil(.975*trials));
meanuq=mean(uqscore);
disp([lower95uq meanuq upper95uq]);