File: FitCumNormYNTest.m

package info (click to toggle)
psychtoolbox-3 3.0.15.20190207.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 101,848 kB
  • sloc: ansic: 174,133; cpp: 11,232; objc: 4,832; sh: 1,874; python: 1,047; php: 384; makefile: 189; java: 113
file content (39 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% FitCumNormYNTest
%
% 9/22/93   jms  Created from FitWeibullYN.
% 2/8/97    dhb  Cleaned up for current calling conventions.

% Upward Sloping Psychometric Function
disp('Fitting an upward sloping psychometric function');

% Set input values
maxInput = 100;
inputs = [1:1:maxInput]';
[m,n] = size(inputs);

% Set parameters and generate some data
uIn =   20;
varIn = 5;
nYes = round(100*NormalCumulative(inputs,uIn,varIn));
nNo = 100-nYes;

% Fit and generate prediction
[uEst,varEst] = FitCumNormYN(inputs,nYes,nNo);
pInputs = [1:maxInput];
predict = NormalCumulative(pInputs,uEst,varEst);

% For comparision, fit a logistic to the same data
[a,b,threshLogit] = FitLogitYN(inputs,nYes,nNo);
predictLogit = ComputeLogistic(pInputs,a,b);

% Print comparision of fit normal and logistic thresholds
fprintf('Normal fit finds threshold at %g, logit at %g\n',uEst,threshLogit);

% Make a plot fo the output
hold off
plot(inputs,nYes./(nYes+nNo),'+');
title('Fit to upward sloping YN psychometric function')
hold on
plot(pInputs,predict,'g');
plot(pInputs,predictLogit,'r');
hold off