%N zedfunc %F $MIR/src/subs/zed.for
%D Return Zeeman maximum likelihood chi**2 value.
%P nebk
%: zeeman
%B
      subroutine ZedFunc(mode,ispect,vspect,m,n,a,b,sigi)

      integer m,n
      real ispect(m,n),vspect(m,n),a,b,sigi
      character mode*(*)
  ---------------------------------------------------------------------
  This returns a normalized value of chi^2, given a and b.

  Inputs:
    mode       Flags to the algorithm. The only recognized flag is '2',
               for two sided derivative.
    ispect,vspect I and V spectra.
    m          Number of channels.
    n          Number of spectra.
    a,b        Alpha and beta parameters of interest.

  Output:
    sigi       Normalized version of chi^2. In particular
               sigi = sqrt{chi^2/((m-1)*n)}
               The expected value of this at the minimum is sigma_I.
