1 Language
                            ADJUST\ Language Summary

    ADJUST : Allows fitting arbitrary data with up to 26 parameters.
1 ADJUST
        [ADJUST\]ADJUST My_Data "My Command" [/START G1 G2 ... Gn] [/STEP S1
    S2  ..  Sn]  [/EPSILON  e]  [/WEIGHTS  w]  [/METHOD   Powell|Robust|Sim‐
    plex|Slatec|Anneal] [/ITER Niter] [/QUIET] [/ROOT_NAME Name] /PARAMETERS
    V1 V2 ... Vn [/BOUNDS Va Lowa Higha [Vb Lowb Highb ...]]

    Allows fitting arbitrary data with (almost) arbitrary number of  parame‐
    ters (well, less than 26 so far, I believe).

    The  command  ADJUST  defines the following global SIC variables to hold
    its results:
           Root%PAR    : Fit parameters
           Root%ERRORS : The parameter errors, if they have been computed
           Root%RES    : Residuals (i.e. My_Data‐Root%FIT)
           Root%STATUS : .FALSE. on successful completion.
    where Root is the name given in the /ROOT_NAME option (default is ADJ or
    MFIT).

    My_Data is a SIC variable containing your data to be fitted. It can be a
    variable of any rank, but (currently) it must be of type DOUBLE.

    "My Command" is a character string specifying the command to be executed
    to  compute  the difference between My_Data and the model.  This differ‐
    ence must be returned in SIC variable Root%RES. The command is typically
            "@ my_difference"
    where "my_difference" is a procedure containing the code to compute  the
    model and a line to compute Root%RES.  Here is a simple example to fit a
    Gaussian (see HELP ADJUST EXAMPLE for more details)
    !
    begin procedure my_difference
       let ADJ%res my_data‐gauss(xx,amp,pos,width)
    end procedure my_difference
2 EXAMPLE

        Here is a complete procedure to generate a noisy  Gaussian  and  fit
    it. The call sequence is

      @ adjust_gaussian Amp Pos Width Noise

    where  Amp  is  the desired amplitude, Pos the position, Width the width
    and Noise the noise on the data.


    ! Procedure ADJUST_GAUSSIAN
    !
    ! An example of ADJUST usage
    ! For simplicity, let us define the GAUSSIAN function
     define function gauss(x,a,b,c) a*exp(‐0.5*((x‐b)/c)^2)
    !
    ! The Gaussian parameters, Amplitude, Position and Width
     define double amp pos width /global
    ! Now the data...
     define double xx[512] my_data[512] /global
    ! Define the Measurement points XX
    let xx[i] 10*(i‐nx/2)/nx
    !
    ! Fill the data with some noisy values. In reality, this may come from
    ! an experiment or observation
    let my_data gauss(xx,&1,&2,&3)
    let my_data[i] myata+&4*noise(i/i)
    !
    begin procedure my_difference
       let ADJ%res my_data‐gauss(xx,amp,pos,width)
    end procedure my_difference
    !
    ! Minimize
    adjust my_data "@ my_difference" /start 3,2,1 /par amp pos width /root ADJ
    exa ADJ%FIT
    exa ADJ%ERR
2 /EPSILON

        This option is used to specify the desired tolerance. Its  interpre‐
    tation  is  method dependent. For SIMPLEX and POWELL, it means the rela‐
    tive deviation of the mean squared difference of two fit iterations. For
    SLATEC,  which uses non‐reduced chi‐2, it is the absolute difference be‐
    tween two iterations. For ANNEAL, its interpretation is totally  differ‐
    ent.

    Use  default  value  0  to let the program guess. In subtle cases, or to
    gain speed in case a coarse result is desired, use  values  around  1D‐5
    for SIMPLEX and POWELL, and of order 1 for SLATEC (provided your weights
    are really 1/sigma^2...). For ANNEAL, see details in the /METHOD option.

    Note that this is not the absolute error of the fit parameters.
2 /METHOD
      ANNEAL  Simulated annealing technique. This may require a  very  large
        number of function evaluation.
      POWELL  Gradient  using  the  Powell  method (see Press et al. for de‐
        tails)
      SIMPLEX Classical Simplex amoeba search
      ROBUST  A combination of Simplex + Slatec, to be used with large  ini‐
        tial steps.
      SLATEC  Modified  Levenberg  Marquardt  method with adaptive steps, as
        implement in the Slatec (LINPACK) library

    All methods require a proper choice of initial values and steps. The AN‐
    NEAL method is much more robust against poor guesses, but may require 10
    to 100 times more function evaluations than any other.
2 /START
        [ADJUST\]ADJUST My_Data "My Command" /START G1 G2 ... Gn

    G1 G2 .. Qn are used to pass starting guesses for the parameters  P1  to
    Pn.  The default is 1.0.  The starting values should not be too far from
    a potential solution, otherwise the convergence may not be possible.
2 /STEP
        [ADJUST\]ADJUST My_Data "My Command" /STEP S1 S2 .. Sn

    S1 S2 .. Sn are used to pass the unity vectors (steps) for the iteration
    on parameters P1 to. Pn. The default depends on the starting guesses Gi:
    Si is equal to abs(0.1 x Gi) or 0.1 if Gi is 0.0 . Poor choice  of  ini‐
    tial  steps  may  lead to non convergence. Too small steps will not help
    converging when one starts too far from the solution.  Too  large  steps
    may  lead  to  incorrect evaluation of the parameter errors. The optimal
    step for the determination of the errors is about the error bar, so that
    all parameters become dimensionless.
2 /PARAMETER
        [ADJUST\]ADJUST  My_Data  "My Command" /PARAMETER  Aname Bname Cname
    [...]

    Defines the parameter names. The parameter names are  Global  SIC  vari‐
    ables  which  are  then used in the user supplied command to compute the
    model. The variables must exist: they are not created by the ADJUST com‐
    mand.
2 /QUIET

        Requires  ADJUST  to be silent (useful to avoid too many messages in
    loops).
2 /WEIGHTS
        [ADJUST\]ADJUST My_Data "My Command" /WEIGHT My_weights

    Define the weights of each data. The array My_Weights must be real,  and
    of same size as the array My_Data.

2 /BOUNDS
        [ADJUST\]ADJUST  My_Data  "My Command" /PARAMETER  Aname Bname Cname
    [...] [/BOUNDS Name1 Low1 High1 [Name2 Low2 High2 ...]]

    Specify the search boundaries for some parameters. This can be useful to
    prevent the  minimization to enter non physical regions. The code does
     not (yet) support one sided boundaries such as [Low, +Inf[

        Caution:
    /BOUNDS  is  still  experimental  and may affect the values of the error
    bars. Please check the result using unbounded minimization once a  mini‐
    mum has been found with a bounded search.

1 ENDOFHELP















































