## Copyright (C) 2004  Rafael Laboissiere
##
## This program is free software. You can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.  If not, write to the
## Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.

## -*- texinfo -*-
## @deftypefn {Function File} {@var{limit} =} [probit_fiducial_interval (@var{t})
## @end deftypefn
##
## @paragraphindent 0
## This function is primarily a helper function for the computation of
## fiducial intervals in the @samp{probit_analysis} function through
## @samp{fsolve}.  This function must be of no practical interest for
## the user.
##
## @seealso{probit_analysis}

## Author: Rafael Laboissiere <rafael@laboissiere.net>
## Description: Finney's probit analysis -- fiducial interval calculations
## $Id$

function limit = probit_fiducial_interval (t)

  ## usage:  limit = probit_fiducial_interval (t)
  ##
  ##

  global probit_analysis_data

  m =  probit_analysis_data.m;
  zm = probit_analysis_data.zm;
  b = probit_analysis_data.b;
  Vb = probit_analysis_data.Vb;
  Vy = probit_analysis_data.Vy;

  ## Eq. 6.4, page 101
  g = t ^ 2 * Vb / b ^ 2;
  limit = m + g * (m - zm) / (1 - g) \
      - (t / (b * (1 - g))) * sqrt ((1 - g) * Vy + Vb * (m - zm) ^ 2);

endfunction
