Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions wave_matlab/chisquare_inv.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@
MAXX = 1; % actually starts at 10 (see while loop below)
X = 1;
TOLERANCE = 1E-4; % this should be accurate enough
vers = version;
vers = str2num(vers(1));

while ((X+TOLERANCE) >= MAXX) % should only need to loop thru once
MAXX = MAXX*10.;
% this calculates value for X, NORMALIZED by V
% Note: We need two different versions, depending upon the version of Matlab.
if (vers >= 6)
X = fminbnd('chisquare_solve',MINN,MAXX,optimset('TolX',TOLERANCE),P,V);
else
X = fmin('chisquare_solve',MINN,MAXX,[0,TOLERANCE],P,V);
end
MINN = MAXX;
MAXX = MAXX*10.;
% this calculates value for X, NORMALIZED by V
X = fminbnd('chisquare_solve',MINN,MAXX,optimset('TolX',TOLERANCE),P,V);
MINN = MAXX;
end

X = X*V; % put back in the goofy V factor
Expand Down