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

« back to all changes in this revision

Viewing changes to Psychtoolbox/Psychometric/WeibTAFCFitFun.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
 
function [f,g] = TAFCFitFun(x,level,nCorrect,nError)
2
 
% [f,g] = TAFCFitFun(x,level,nCorrect,nError)
 
1
function [f,g] = WeibTAFCFitFun(x,level,nCorrect,nError)
 
2
% [f,g] = WeibTAFCFitFun(x,level,nCorrect,nError)
3
3
%
4
4
% 8/26/94               dhb, ccc        Fix range checking bug left from YN conversion.
5
5
 
8
8
beta  = x(2);
9
9
 
10
10
% Force really big error if alpha or beta <= 0
11
 
if (alpha <= 0 | beta <= 0)
12
 
        f = 1e25;
13
 
        g = -1;
14
 
        return;
 
11
if (alpha <= 0 || beta <= 0)
 
12
    f = 1e25;
 
13
    g = -1;
 
14
    return;
15
15
end
16
16
 
17
17
% Compute Weibull function on input levels
21
21
tol = 1e-4;
22
22
o_index = find(pCorrect == 1);
23
23
if (~isempty(o_index))
24
 
  pCorrect(o_index) = (1-tol)*ones(length(o_index),1);
 
24
    pCorrect(o_index) = (1-tol)*ones(length(o_index),1);
25
25
end
26
 
  
 
26
 
27
27
% Compute error function, which is -log(likelihood).
28
28
tmp = nCorrect.*log(pCorrect) + nError.*log(1 - pCorrect);
29
29
f =  -sum(tmp);
30
30
g = -1;
31
 
 
32
 
 
33
 
 
34
 
 
35
 
 
36