Debian Codegraph @

applic/statist/src/comp2sam.for

raw
1 C @(#)comp2sam.for 19.1 (ES0-DMD) 02/25/03 13:21:26
2 C===========================================================================
3 C Copyright (C) 1995 European Southern Observatory (ESO)
4 C
5 C This program is free software; you can redistribute it and/or
6 C modify it under the terms of the GNU General Public License as
7 C published by the Free Software Foundation; either version 2 of
8 C the License, or (at your option) any later version.
9 C
10 C This program is distributed in the hope that it will be useful,
11 C but WITHOUT ANY WARRANTY; without even the implied warranty of
12 C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 C GNU General Public License for more details.
14 C
15 C You should have received a copy of the GNU General Public
16 C License along with this program; if not, write to the Free
17 C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
18 C MA 02139, USA.
19 C
20 C Corresponding concerning ESO-MIDAS should be addressed as follows:
21 C Internet e-mail: [email protected]
22 C Postal address: European Southern Observatory
23 C Data Management Division
24 C Karl-Schwarzschild-Strasse 2
25 C D 85748 Garching bei Muenchen
26 C GERMANY
27 C===========================================================================
28 C
29 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 C.COPYRIGHT: Copyright (c) 1987 European Southern Observatory,
31 C all rights reserved
32 C
33 C.VERSION: 1.0 ESO-FORTRAN Conversion, AA 5 JUL 1989
34 C
35 C.LANGUAGE: F77+ESOext
36 C
37 C.AUTHOR: M.PERON
38 C
39 C.IDENTIFICATION
40 C
41 C Program COMP2SAM
42 C
43 C.KEYWORDS
44 C
45 C KOLMOGOROV, SIGN, WILCOXON
46 C
47 C.PURPOSE
48 C
49 C Comparaison of two data sets using
50 C - Kolmogorov Test
51 C - Sign Test - NOT IMPLEMENTED YET-
52 C - Wilcoxon Test - NOT IMPLEMENTED YET-
53 C - Mann-Whitney U test -NOT IMPLEMENTED YET-
54 C-----------------------------------------------------------
55 C
56 PROGRAM COMP2SAM
57 REAL D,PROB
58 INTEGER MADRID
59 INTEGER*8 ADDRIN(4)
60 INTEGER NSC,KUN
61 INTEGER*4 PARVAL,NPAR,ISTAT,TID,NCOL,NROW,NACOL,NAROW,COL1,COL2
62 INTEGER*4 NBYTES,NREAL
63 CHARACTER*80 INTAB,OUTPUT1,OUTPUT2,OUTPUT3,OUT,OUTPUT0
64 CHARACTER*17 COLIND,COLDEP
65 INCLUDE 'MID_INCLUDE:TABLES.INC'
66 COMMON/VMR/MADRID(1)
67 INCLUDE 'MID_INCLUDE:TABLED.INC'
68 DATA PARVAL/8/
69 DATA OUTPUT0
70 1 /' Null Hypothesis: the two data sets come
71 2 from the same distribution'/
72 DATA OUTPUT1
73 3 /'Kolmogorov-Smirnov D Statistic '/
74 DATA OUTPUT2
75 4 /'Probability of exceeding D under Null Hypothesis'/
76 DATA OUTPUT3
77 5 /'----------------------------------------------------------'/
78 CALL STSPRO('COMP2SAM')
79 CALL TDPGET(PARVAL,NPAR,ISTAT)
80 IF (ISTAT.NE.0) GOTO 80
81 INTAB = TPARBF(1)
82 COLIND = TPARBF(2)
83 COLDEP = TPARBF(3)
84 CALL TBTOPN(INTAB,F_U_MODE,TID,ISTAT)
85 IF(ISTAT.NE.0) GOTO 80
86 CALL TBIGET(TID,NCOL,NROW,NSC,NACOL,NAROW,ISTAT)
87 CALL TBCSER(TID,COLIND,COL1,ISTAT)
88 IF (COL1.LT.0) THEN
89 CALL STTPUT('Column not found...',ISTAT)
90 GOTO 80
91 ENDIF
92 CALL TBCSER(TID,COLDEP,COL2,ISTAT)
93 IF (COL2.LT.0) THEN
94 CALL STTPUT('Column not found...',ISTAT)
95 GOTO 80
96 ENDIF
97 NBYTES = 4*NROW
98 CALL TDMGET(NBYTES,ADDRIN(1),ISTAT)
99 CALL TDMGET(NBYTES,ADDRIN(2),ISTAT)
100 CALL TMAP2(TID,NROW,COL1,COL2,MADRID(ADDRIN(1)),
101 1 MADRID(ADDRIN(2)),NREAL)
102 CALL SORT (MADRID(ADDRIN(1)),NREAL)
103 CALL SORT (MADRID(ADDRIN(2)),NREAL)
104 CALL KOLM2DIS(MADRID(ADDRIN(1)),NROW,MADRID(ADDRIN(2)),
105 1 NREAL,D,PROB)
106 CALL STKWRR('OUTPUTR',D,1,1,KUN,ISTAT)
107 CALL STKWRR('OUTPUTR',PROB,2,1,KUN,ISTAT)
108 CALL STTPUT(OUTPUT0,ISTAT)
109 CALL STTPUT(OUTPUT3,ISTAT)
110 WRITE(OUT,100)D
111 CALL STTPUT(OUTPUT1,ISTAT)
112 CALL STTPUT(OUT,ISTAT)
113 CALL STTPUT(OUTPUT3,ISTAT)
114 CALL STTPUT(OUTPUT2,ISTAT)
115 WRITE(OUT,100)PROB
116 CALL STTPUT(OUT,ISTAT)
117 CALL STTPUT(OUTPUT3,ISTAT)
118
119 C IF (ACTION.EQ.'SIGN') THEN
120 C CALL SIGN(MADRID(ADDRIN(1)),MADRID(ADDRIN(2)),NROW)
121 C ENDIF
122 C IF (ACTION.EQ.'WILC') THEN
123 C CALL TDMGET(NBYTES,ADDRIN(3),ISTAT)
124 C CALL TDMGET(NBYTES,ADDRIN(4),ISTAT)
125 C CALL WILC(MADRID(ADDRIN(1)),MADRID(ADDRIN(2)),MADRID(ADDRIN(3)),
126 C 1 MADRID(ADDRIN(4)),NROW,S)
127 C MEAN = NROW*(NROW+1)/4
128 C SIGMA = NROW*(NROW+1)*(2*NROW+1)/24
129 C PROB = ERFCC((S-MEAN)/SQRT(2.*SIGMA))
130 C CALL STKWRR('OUTPUTR',S,1,1,KUN,ISTAT)
131 C CALL STKWRR('OUTPUTR',PROB,2,1,KUN,ISTAT)
132 C WRITE(OUT,100)S,PROB
133 C CALL STTPUT(OUTPUT2,ISTAT)
134 C CALL STTPUT(OUTPUT3,ISTAT)
135 C CALL STTPUT(OUT,ISTAT)
136 C ENDIF
137 CALL TBTCLO(TID,ISTAT)
138 CALL STSEPI
139 80 CONTINUE
140 100 FORMAT(1X,G15.6,15X,G15.6)
141 END
142