File: FitGammaPolyR.m

package info (click to toggle)
psychtoolbox-3 3.0.9%2Bsvn2579.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 63,408 kB
  • sloc: ansic: 73,310; cpp: 11,139; objc: 3,129; sh: 1,669; python: 382; php: 272; makefile: 172; java: 113
file content (38 lines) | stat: -rwxr-xr-x 1,118 bytes parent folder | download | duplicates (2)
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
function [fit_out,x,err] = FitGammaPolyR(values_in,measurements,values_out)
% [fit_out,x,err] = FitGammaPolyR(values_in,measurements,values_out)
%
% Fit homogeneous polynomial to gamma data.
% No forced normalization or non-negativity
%
% 10/20/93    dhb   Wrote it.
% 11/9/93     dhb   Modified to force initial zero entries to be fit with zero.

% Allocate return space
[mOut,nOut] = size(values_out);
fit_out = zeros(mOut,nOut);

% Find first non-zero entry
[mIn,nIn] = size(values_in);
index = find(measurements ~= 0.0);
if (~isempty(index))
  useIndex = index(1);
  useIn = values_in(useIndex:mIn,1);
  useMeas = measurements(useIndex:mIn,1);

  % Get initial values
  x0 = InitialXPolyR(useIn,useMeas);
  x = x0;

  % Compute fit values and error to data for return
  zeroThresh = values_in(useIndex);
  fitOutIndex = find(values_out >= zeroThresh);
  fitInIndex = find(values_in >= zeroThresh);  
  fit_out(fitOutIndex) = ComputeGammaPolyR(x,values_out(fitOutIndex));
  fit_in = ComputeGammaPolyR(x,values_in(fitInIndex));
  err = ComputeRMSE(fit_in,measurements(fitInIndex));
else
  x = [];
  err = 0.0;
end