~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychTests/QuestTest.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
% QuestTest.m
 
 
b'%'
 
 
b'% Created by hacking a copy of QuestDemo.m, in order to'
 
 
b'% do some simulations for Beau Watson.'
 
 
b'%'
 
 
b'% 128 repetitions of each condition'
 
 
b'% Quest assumes LogWeibull psychometric function with parameters:'
 
 
b'% beta = {1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5} (in separate conditions)'
 
 
b'% gamma = 0.03'
 
 
b'% delta = .01'
 
 
b'% sample range = {-30,30} dB'
 
 
b'% sample step size 0.5 dB'
 
 
b'% Prior is always Gaussian, sd=12 dB, centered on guess.'
 
 
b'% Initial guess drawn from Normal distribution with mean 0 and sd=6 dB.'
 
 
b'% Quest uses mode of posterior density.'
 
 
b'% Simulated observer has LogWeibull psychometric function with parameters:'
 
 
b'% {beta=3.5,gamma=.03,delta=.01}'
 
 
b'%'
 
 
b'%'
 
 
b'% By commenting and uncommenting five lines below, you can use'
 
 
b'% this file to implement three QUEST-related procedures for measuring'
 
 
b'% threshold.'
 
 
b'%'
 
 
b'% QuestMode: In the original algorithm of Watson & Pelli (1983)'
 
 
b'% each trial and the final estimate are at the MODE of the posterior pdf.'
 
 
b'%'
 
 
b'% QuestMean: In the improved algorithm of King-Smith et al. (1994).'
 
 
b'% each trial and the final estimate are at the MEAN of the posterior pdf.'
 
 
b'%'
 
 
b'% QuestQuantile & QuestMean: In the ideal algorithm of Pelli (1987)'
 
 
b'% each trial is at the best QUANTILE, and the final estimate is at '
 
 
b'% the MEAN of the posterior pdf.'
 
 
b'%'
 
 
b'% King-Smith, P. E., Grigsby, S. S., Vingrys, A. J., Benes, S. C., and Supowit, A.'
 
 
b'% (1994) Efficient and unbiased modifications of the QUEST threshold method: theory, '
 
 
b'% simulations, experimental evaluation and practical implementation. '
 
 
b'% Vision Res, 34 (7), 885-912.'
 
 
b'%'
 
 
b'% Pelli, D. G. (1987) The ideal psychometric procedure. Investigative Ophthalmology '
 
 
b'% & Visual Science, 28 (Suppl), 366.'
 
 
b'%'
 
 
b'% Watson, A. B. and Pelli, D. G. (1983) QUEST: a Bayesian adaptive psychometric '
 
 
b'% method. Percept Psychophys, 33 (2), 113-20.'
 
 
b'%'
 
 
b'% Copyright (c) 1996-1997 Denis G. Pelli'
 
 
b'%'
 
 
b'% 6/24/97  dgp\twrote it, based on QuestDemo.m'
 
 
b"fprintf('beta\tmean\tsd\t\treps\\n')"
 
 
b'reps=64;'
 
 
b'for beta = [1.5:.5:5.5]'
 
 
b'\testimate=1:reps;'
 
 
b'\tfor i=1:reps'
 
 
b'\t\tgamma = 0.03;'
 
 
b'\t\tdelta = .01;'
 
 
b'\t\ttGuess=randn*6/20;'
 
 
b'\t\ttGuessSd=12/20;'
 
 
b'\t\trange = 3;'
 
 
b'\t\tgrain=0.5/20;'
 
 
b'\t\tpThreshold=0.6370;'
 
 
b'\t\ttActual=0;'
 
 
b'\t\ttrialsDesired=64;'
 
 
b"\t\twrongRight=str2mat('wrong','right');"
 
 
b'\t\tq=QuestCreate(tGuess,tGuessSd,pThreshold,beta,delta,gamma,grain,range);'
 
 
b'\t\tqObserver=QuestCreate(tActual,tGuessSd,pThreshold,3.5,delta,gamma,grain,range);'
 
 
b"\t\t%fprintf('Quest estimate of thresh after initialization is %g\\n',QuestMean(q));"
 
 
b"\t\t%fprintf('Initial value was %g\\n',tGuess);"
 
 
b"\t\t%fprintf('Quest estimate of sd after initialization is %g\\n',QuestSd(q));"
 
 
b"\t\t%fprintf('Initial value was %g\\n',tGuessSd);"
 
 
b'\t\t'
 
 
b'\t\tfor k=1:trialsDesired'
 
 
b'\t\t\ttTest=QuestMode(q);\t% 0.03 s'
 
 
b'\t\t \tresponse=QuestSimulate(qObserver,tTest,tActual); % 0.10 s'
 
 
b'\t\t\tq=QuestUpdate(q,tTest,response); % 0.10 s'
 
 
b'\t\tend'
 
 
b'\t\tt=QuestMode(q);'
 
 
b"\t\t%fprintf('%4.1f\\t%+6.3f\\n',beta,t);"
 
 
b'\t\testimate(i)=t;'
 
 
b'\tend'
 
 
b"\tfprintf('%4.1f\\t%+6.3f\\t%5.3f\\t%d\\n',beta,mean(estimate),std(estimate),length(estimate));"
 
 
b'end'
 
 
b'\t'
 
 
b'\t\t'
 
 
b'\t\t'
 
 
b'\\ No newline at end of file'
 
1
% QuestTest.m
 
2
%
 
3
% Created by hacking a copy of QuestDemo.m, in order to
 
4
% do some simulations for Beau Watson.
 
5
%
 
6
% 128 repetitions of each condition
 
7
% Quest assumes LogWeibull psychometric function with parameters:
 
8
% beta = {1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5} (in separate conditions)
 
9
% gamma = 0.03
 
10
% delta = .01
 
11
% sample range = {-30,30} dB
 
12
% sample step size 0.5 dB
 
13
% Prior is always Gaussian, sd=12 dB, centered on guess.
 
14
% Initial guess drawn from Normal distribution with mean 0 and sd=6 dB.
 
15
% Quest uses mode of posterior density.
 
16
% Simulated observer has LogWeibull psychometric function with parameters:
 
17
% {beta=3.5,gamma=.03,delta=.01}
 
18
%
 
19
%
 
20
% By commenting and uncommenting five lines below, you can use
 
21
% this file to implement three QUEST-related procedures for measuring
 
22
% threshold.
 
23
%
 
24
% QuestMode: In the original algorithm of Watson & Pelli (1983)
 
25
% each trial and the final estimate are at the MODE of the posterior pdf.
 
26
%
 
27
% QuestMean: In the improved algorithm of King-Smith et al. (1994).
 
28
% each trial and the final estimate are at the MEAN of the posterior pdf.
 
29
%
 
30
% QuestQuantile & QuestMean: In the ideal algorithm of Pelli (1987)
 
31
% each trial is at the best QUANTILE, and the final estimate is at 
 
32
% the MEAN of the posterior pdf.
 
33
%
 
34
% King-Smith, P. E., Grigsby, S. S., Vingrys, A. J., Benes, S. C., and Supowit, A.
 
35
% (1994) Efficient and unbiased modifications of the QUEST threshold method: theory, 
 
36
% simulations, experimental evaluation and practical implementation. 
 
37
% Vision Res, 34 (7), 885-912.
 
38
%
 
39
% Pelli, D. G. (1987) The ideal psychometric procedure. Investigative Ophthalmology 
 
40
% & Visual Science, 28 (Suppl), 366.
 
41
%
 
42
% Watson, A. B. and Pelli, D. G. (1983) QUEST: a Bayesian adaptive psychometric 
 
43
% method. Percept Psychophys, 33 (2), 113-20.
 
44
%
 
45
% Copyright (c) 1996-1997 Denis G. Pelli
 
46
%
 
47
% 6/24/97  dgp  wrote it, based on QuestDemo.m
 
48
 
 
49
fprintf('beta   mean    sd              reps\n')
 
50
reps=64;
 
51
for beta = [1.5:.5:5.5]
 
52
        estimate=1:reps;
 
53
        for i=1:reps
 
54
                gamma = 0.03;
 
55
                delta = .01;
 
56
                tGuess=randn*6/20;
 
57
                tGuessSd=12/20;
 
58
                range = 3;
 
59
                grain=0.5/20;
 
60
                pThreshold=0.6370;
 
61
                tActual=0;
 
62
                trialsDesired=64;
 
63
                wrongRight=char('wrong','right');
 
64
                q=QuestCreate(tGuess,tGuessSd,pThreshold,beta,delta,gamma,grain,range);
 
65
                qObserver=QuestCreate(tActual,tGuessSd,pThreshold,3.5,delta,gamma,grain,range);
 
66
                %fprintf('Quest estimate of thresh after initialization is %g\n',QuestMean(q));
 
67
                %fprintf('Initial value was %g\n',tGuess);
 
68
                %fprintf('Quest estimate of sd after initialization is %g\n',QuestSd(q));
 
69
                %fprintf('Initial value was %g\n',tGuessSd);
 
70
                
 
71
                for k=1:trialsDesired
 
72
                        tTest=QuestMode(q);     % 0.03 s
 
73
                        response=QuestSimulate(qObserver,tTest,tActual); % 0.10 s
 
74
                        q=QuestUpdate(q,tTest,response); % 0.10 s
 
75
                end
 
76
                t=QuestMode(q);
 
77
                %fprintf('%4.1f\t%+6.3f\n',beta,t);
 
78
                estimate(i)=t;
 
79
        end
 
80
        fprintf('%4.1f\t%+6.3f\t%5.3f\t%d\n',beta,mean(estimate),std(estimate),length(estimate));
 
81
end
 
82
        
 
83
                
 
84