next up previous contents index
Next: ADJUST /EPSILON Up: ADJUST Previous: ADJUST   Contents   Index


ADJUST Example

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

      @ gagemo:demo-adjust Amp Pos Width Noise

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

    ! Procedure gag_demo:demo-adjust
    !
    ! 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 integer nx
     let nx 512
     define double xx[nx] my_data[nx] /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] my_data+&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
    examine ADJ%PAR
    examine ADJ%ERRORS


Gildas manager 2024-03-28