1 | DOUBLE PRECISION FUNCTION CHISQ(F)
|
---|
2 |
|
---|
3 | C-----------------------------------------------------------------------
|
---|
4 | C CHI SQ(UARE)
|
---|
5 | C
|
---|
6 | C THIS FUNCTION CALCULATES THE CHI**2 OBTAINED WITH THE FITFUNCTION
|
---|
7 | C AMOEBA USING THE PARAMETER SET F
|
---|
8 | C F(1) = HEIGHT AT MAXIMUM
|
---|
9 | C F(2) = SHOWER STARTING POINT
|
---|
10 | C F(3) = T AT MAXIMUM
|
---|
11 | C F(4) = WIDTH PARAMETER 1
|
---|
12 | C F(5) = WIDTH PARAMETER 2 T
|
---|
13 | C F(6) = WIDTH PARAMETER 3 T**2
|
---|
14 | C THIS FUNCTION IS CALLED FROM LONGFT AND FROM AMOEBA
|
---|
15 | C-----------------------------------------------------------------------
|
---|
16 |
|
---|
17 | IMPLICIT NONE
|
---|
18 | *KEEP,CURVE.
|
---|
19 | COMMON /CURVE/ CHAPAR,DEP,ERR,NSTP
|
---|
20 | DOUBLE PRECISION CHAPAR(1100),DEP(1100),ERR(1100)
|
---|
21 | INTEGER NSTP
|
---|
22 | *KEEP,RUNPAR.
|
---|
23 | COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
|
---|
24 | * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
|
---|
25 | * MONIOU,MDEBUG,NUCNUC,
|
---|
26 | * CETAPE,
|
---|
27 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
28 | * N1STTR,MDBASE,
|
---|
29 | * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
30 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
31 | * ,GHEISH,GHESIG
|
---|
32 | COMMON /RUNPAC/ DSN,HOST,USER
|
---|
33 | DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
|
---|
34 | REAL STEPFC
|
---|
35 | INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
|
---|
36 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
37 | * N1STTR,MDBASE
|
---|
38 | INTEGER CETAPE
|
---|
39 | CHARACTER*79 DSN
|
---|
40 | CHARACTER*20 HOST,USER
|
---|
41 |
|
---|
42 | LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
43 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
44 | * ,GHEISH,GHESIG
|
---|
45 | *KEND.
|
---|
46 |
|
---|
47 | DOUBLE PRECISION AUXIL,BALL,BASE,EXPO,F(6),T
|
---|
48 | INTEGER I
|
---|
49 | C-----------------------------------------------------------------------
|
---|
50 |
|
---|
51 | IF ( DEBUG ) WRITE(MDEBUG,*) 'CHISQ : PARAMETERS =',F
|
---|
52 |
|
---|
53 | C EXCLUDE PATHOLOGICAL PARAMETER SETTINGS
|
---|
54 | IF ( F(1) .LE. 0.D0 .OR. F(2) .GE. F(3) .OR.
|
---|
55 | * (F(4).EQ.0.D0 .AND. F(5).EQ.0.D0 .AND. F(6).EQ.0.D0) ) THEN
|
---|
56 | CHISQ = 1.D16
|
---|
57 | RETURN
|
---|
58 | ENDIF
|
---|
59 |
|
---|
60 | CHISQ = 0.D0
|
---|
61 | C LOOP OVER THE LONGITUDINAL DISTRIBUTION
|
---|
62 | DO 1 I=1,NSTP
|
---|
63 | T = DEP(I)
|
---|
64 | IF ( T .GT. F(2) ) THEN
|
---|
65 | BASE = (T-F(2)) / (F(3)-F(2))
|
---|
66 | AUXIL = F(4) + T*F(5) + T**2*F(6)
|
---|
67 | IF ( AUXIL .LT. 1.D-20 ) THEN
|
---|
68 | CHISQ = CHISQ + 1.D16
|
---|
69 | GOTO 1
|
---|
70 | ENDIF
|
---|
71 | EXPO = (F(3)-T) / AUXIL
|
---|
72 | CC IF(DEBUG)WRITE(MDEBUG,*)'CHISQ : I,BASE,EXPO=',I,
|
---|
73 | CC * SNGL(BASE),SNGL(EXPO)
|
---|
74 | BALL = F(1) * BASE ** EXPO
|
---|
75 | ELSE
|
---|
76 | BALL = 0.D0
|
---|
77 | ENDIF
|
---|
78 | CHISQ = CHISQ + ((BALL-CHAPAR(I))/ERR(I))**2
|
---|
79 | 1 CONTINUE
|
---|
80 | CHISQ = CHISQ / (NSTP-6)
|
---|
81 |
|
---|
82 | IF ( DEBUG ) WRITE(MDEBUG,*) 'CHISQ : CHI**2 =',SNGL(CHISQ)
|
---|
83 |
|
---|
84 | RETURN
|
---|
85 | END
|
---|