File: FitLogistic.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (27 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (7)
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
function [a,b] = FitLogistic(x,y)
% [a,b] = FitLogistic(x,y)
% 
% Fit a logistic function to the data pairs x,y.
%
% The form of the logistic equation is y = 1/(1+10^-(ax+b)).
% The method used here is to regres on transformed coordinates.
% One could use search to do a maximum likelihood function for
% psychometric data, but if you are going to do that, you
% should probably fit a cumulative normal or Weibull function.
%
% See also: ComputeLogistic, InvertLogistic, FitLogitYN, FitWeibTAFC, 
%   FitWeibYN, FitAlphaWeibTAFC.
%
% 2/15/95		dhb		Wrote it.

% Get rid of bad values
index = find( y == 0 );
y(index) = 0.001*ones(size(index));
index = find( y == 1 );
y(index) = 0.999*ones(size(index));

regresY = log10( (1-y) ./ y );
ab = [x ones(size(x))]\regresY;
a = -ab(1);
b = -ab(2);