Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!! !!!!
4 : !!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5 : !!!! !!!!
6 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7 : !!!! !!!!
8 : !!!! This file is part of the ParaMonte library. !!!!
9 : !!!! !!!!
10 : !!!! LICENSE !!!!
11 : !!!! !!!!
12 : !!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13 : !!!! !!!!
14 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 :
17 : !> \brief
18 : !> This include file contains the implementation of procedures in [pm_distanceKolm](@ref pm_distanceKolm).
19 : !>
20 : !> \finmain
21 : !>
22 : !> \author
23 : !> \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : #if WII_ENABLED || WID_ENABLED
28 : #define TYPE_OF_WEIGHT integer(IK)
29 : #elif WRR_ENABLED || WRD_ENABLED
30 : #define TYPE_OF_WEIGHT real(TKC)
31 : #elif !WDD_ENABLED
32 : #error "Unrecognized interface."
33 : #endif
34 : #if SXD_ENABLED || SXA_ENABLED
35 : #define CDF_ARG
36 : #elif SCD_ENABLED || SCA_ENABLED
37 : #define CDF_ARG, getCDF
38 : #elif !(SSD_ENABLED || SSA_ENABLED)
39 : #error "Unrecognized interface."
40 : #endif
41 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 : #if getDisKolm_ENABLED && (SXD_ENABLED || SCD_ENABLED) && WDD_ENABLED
43 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 :
45 80 : real(TKC) :: copySample1(size(sample1, 1, IK))
46 935 : copySample1 = sample1
47 80 : call setDisKolm(disKolm, copySample1 CDF_ARG)
48 :
49 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 : #elif setDisKolm_ENABLED && (SXD_ENABLED || SCD_ENABLED) && WDD_ENABLED
51 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 :
53 80 : call setSorted(sample1)
54 80 : call setDisKolm(disKolm, sample1 CDF_ARG, ascending)
55 :
56 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 : #elif (getDisKolm_ENABLED || setDisKolm_ENABLED) && (SXA_ENABLED || SCA_ENABLED) && WDD_ENABLED
58 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 :
60 : integer(IK) :: isam1, nsam1
61 : real(TKC) :: invWeiSum1, cdfn, cdfp, cdfr ! next, previous, reference
62 : !check_assertion(__LINE__, 0 < size(sample1, 1, IK), SK_"@setDisKolm(): The condition `0 < size(sample1)` must hold. size(sample1) = "//getStr(size(sample1, 1, IK)))
63 100 : CHECK_ASSERTION(__LINE__, isAscending(sample1), SK_"@setDisKolm(): The condition `isAscending(sample1)` must hold. sample1 = "//getStr(sample1))
64 : #if SXA_ENABLED
65 1006 : CHECK_ASSERTION(__LINE__, all(0 <= sample1) .and. all(sample1 <= 1), SK_"@setDisKolm(): The condition `all(0 <= sample1) .and. all(sample1 <= 1)` must hold. sample1 = "//getStr(sample1))
66 : #endif
67 100 : nsam1 = size(sample1, 1, IK)
68 100 : if (0 < nsam1) invWeiSum1 = 1._TKC / nsam1
69 80 : disKolm = 0._TKC
70 0 : cdfp = 0._TKC
71 1053 : do isam1 = 1, nsam1
72 : #if SXA_ENABLED
73 453 : cdfr = sample1(isam1)
74 : #elif SCA_ENABLED
75 500 : cdfr = getCDF(sample1(isam1))
76 1500 : CHECK_ASSERTION(__LINE__, 0 <= cdfr .and. cdfr <= 1, SK_"@setDisKolm(): The condition `0 <= getCDF(sample1(isam1)) <= 1` must hold. sample1(isam1), getCDF(sample1(isam1)) = "//getStr([sample1(isam1), cdfr]))
77 : #else
78 : #error "Unrecognized interface."
79 : #endif
80 953 : cdfn = isam1 * invWeiSum1
81 953 : disKolm = max(disKolm, abs(cdfr - cdfp), abs(cdfr - cdfn))
82 100 : cdfp = cdfn
83 : end do
84 :
85 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 : #elif getDisKolm_ENABLED && (SXD_ENABLED || SCD_ENABLED) && (WID_ENABLED | WRD_ENABLED)
87 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 :
89 240 : TYPE_OF_WEIGHT :: copyWeight1(size(weight1, 1, IK))
90 120 : real(TKC) :: copySample1(size(sample1, 1, IK))
91 866 : copySample1 = sample1
92 866 : copyWeight1 = weight1
93 120 : call setDisKolm(disKolm, copySample1, copyWeight1, weisum1 CDF_ARG)
94 :
95 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 : #elif setDisKolm_ENABLED && (SXD_ENABLED || SCD_ENABLED) && (WID_ENABLED | WRD_ENABLED)
97 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 :
99 240 : integer(IK) :: index1(size(sample1, 1, IK))
100 120 : call setSorted(sample1, index1)
101 1732 : sample1 = sample1(index1)
102 1732 : weight1 = weight1(index1)
103 120 : call setDisKolm(disKolm, sample1, weight1, weisum1 CDF_ARG, ascending)
104 :
105 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 : #elif (getDisKolm_ENABLED || setDisKolm_ENABLED) && (SXA_ENABLED || SCA_ENABLED) && (WID_ENABLED | WRD_ENABLED)
107 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 :
109 : integer(IK) :: isam1, nsam1
110 : real(TKC) :: invWeiSum1, cdfn, cdfp, cdfr ! next, previous, reference
111 866 : CHECK_ASSERTION(__LINE__, all(0 <= weight1), SK_"@setDisKolm(): The condition `all(0 <= weight1)` must hold. weight1 = "//getStr(sample1))
112 120 : CHECK_ASSERTION(__LINE__, isAscending(sample1), SK_"@setDisKolm(): The condition `isAscending(sample1)` must hold. sample1 = "//getStr(sample1))
113 : #if SXA_ENABLED
114 772 : CHECK_ASSERTION(__LINE__, all(0 <= sample1) .and. all(sample1 <= 1), SK_"@setDisKolm(): The condition `all(0 <= sample1) .and. all(sample1 <= 1)` must hold. sample1 = "//getStr(sample1))
115 : #endif
116 1852 : CHECK_ASSERTION(__LINE__, abs(weisum1 - sum(weight1)) < 100 * epsilon(0._TKC), SK_"@setDisKolm(): The condition `weisum1 == sum(weight1)` must hold. weisum1, sum(weight1) = "//getStr([weisum1, sum(weight1)]))
117 360 : CHECK_ASSERTION(__LINE__, size(sample1, 1, IK) == size(weight1, 1, IK), SK_"@setDisKolm(): The condition `size(sample1) == size(weight1)` must hold. size(sample1), size(weight1) = "//getStr([size(sample1, 1, IK), size(weight1, 1, IK)]))
118 : nsam1 = size(sample1, 1, IK)
119 120 : if (0 < weisum1) invWeiSum1 = 1._TKC / weisum1
120 120 : disKolm = 0._TKC
121 0 : cdfn = 0._TKC
122 0 : cdfp = 0._TKC
123 866 : do isam1 = 1, nsam1
124 : #if SXA_ENABLED
125 326 : cdfr = sample1(isam1)
126 : #elif SCA_ENABLED
127 420 : cdfr = getCDF(sample1(isam1))
128 1260 : CHECK_ASSERTION(__LINE__, 0 <= cdfr .and. cdfr <= 1, SK_"@setDisKolm(): The condition `0 <= getCDF(sample1(isam1)) <= 1` must hold. sample1(isam1), getCDF(sample1(isam1)) = "//getStr([sample1(isam1), cdfr]))
129 : #else
130 : #error "Unrecognized interface."
131 : #endif
132 746 : cdfn = cdfn + weight1(isam1) * invWeiSum1
133 746 : disKolm = max(disKolm, abs(cdfr - cdfp), abs(cdfr - cdfn))
134 120 : cdfp = cdfn
135 : end do
136 :
137 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 : #elif getDisKolm_ENABLED && SSD_ENABLED && WDD_ENABLED
139 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140 :
141 100 : real(TKC) :: copySample1(size(sample1, 1, IK))
142 50 : real(TKC) :: copySample2(size(sample2, 1, IK))
143 609 : copySample1 = sample1
144 447 : copySample2 = sample2
145 50 : call setDisKolm(disKolm, copySample1, copySample2)
146 :
147 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 : #elif setDisKolm_ENABLED && SSD_ENABLED && WDD_ENABLED
149 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 :
151 60 : call setSorted(sample1)
152 60 : call setSorted(sample2)
153 60 : call setDisKolm(disKolm, sample1, sample2, ascending)
154 :
155 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 : #elif (getDisKolm_ENABLED || setDisKolm_ENABLED) && SSA_ENABLED && WDD_ENABLED
157 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 :
159 : real(TKC) :: cdf1, cdf2
160 : real(TKC) :: ell1, ell2
161 : integer(IK) :: isam1, isam2
162 : integer(IK) :: nsam1, nsam2
163 : real(TKC) :: invWeiSum1, invWeiSum2
164 100 : CHECK_ASSERTION(__LINE__, isAscending(sample1), SK_"@setDisKolm(): The condition `isAscending(sample1)` must hold. sample1 = "//getStr(sample1))
165 100 : CHECK_ASSERTION(__LINE__, isAscending(sample2), SK_"@setDisKolm(): The condition `isAscending(sample2)` must hold. sample2 = "//getStr(sample2))
166 100 : nsam1 = size(sample1, 1, IK)
167 100 : nsam2 = size(sample2, 1, IK)
168 100 : if (0_IK < nsam1) invWeiSum1 = 1._TKC / nsam1
169 100 : if (0_IK < nsam2) invWeiSum2 = 1._TKC / nsam2
170 : isam1 = 1_IK
171 : isam2 = 1_IK
172 0 : cdf1 = 0._TKC
173 0 : cdf2 = 0._TKC
174 90 : disKolm = 0._TKC
175 1397 : do
176 1497 : if (nsam1 < isam1 .or. nsam2 < isam2) exit
177 1397 : ell1 = sample1(isam1)
178 1397 : ell2 = sample2(isam2)
179 1397 : if (ell1 <= ell2) then
180 849 : cdf1 = isam1 * invWeiSum1
181 849 : isam1 = isam1 + 1_IK
182 : end if
183 1397 : if (ell2 <= ell1) then
184 548 : cdf2 = isam2 * invWeiSum2
185 548 : isam2 = isam2 + 1_IK
186 : end if
187 1497 : disKolm = max(disKolm, abs(cdf2 - cdf1))
188 : end do
189 :
190 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 : #elif getDisKolm_ENABLED && SSD_ENABLED && (WID_ENABLED | WRD_ENABLED)
192 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
193 :
194 120 : TYPE_OF_WEIGHT :: copyWeight1(size(weight1, 1, IK))
195 120 : real(TKC) :: copySample1(size(sample1, 1, IK))
196 60 : real(TKC) :: copySample2(size(sample2, 1, IK))
197 378 : copySample1 = sample1
198 388 : copySample2 = sample2
199 378 : copyWeight1 = weight1
200 60 : call setDisKolm(disKolm, copySample1, copyWeight1, weisum1, copySample2)
201 :
202 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 : #elif setDisKolm_ENABLED && SSD_ENABLED && (WID_ENABLED | WRD_ENABLED)
204 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 :
206 160 : integer(IK) :: index1(size(sample1, 1, IK))
207 80 : call setSorted(sample1, index1)
208 1032 : sample1 = sample1(index1)
209 1032 : weight1 = weight1(index1)
210 80 : call setSorted(sample2)
211 80 : call setDisKolm(disKolm, sample1, weight1, weisum1, sample2, ascending)
212 :
213 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 : #elif (getDisKolm_ENABLED || setDisKolm_ENABLED) && SSA_ENABLED && (WID_ENABLED | WRD_ENABLED)
215 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 :
217 : real(TKC) :: cdf1, cdf2
218 : real(TKC) :: ell1, ell2
219 : integer(IK) :: isam1, isam2
220 : integer(IK) :: nsam1, nsam2
221 : real(TKC) :: invWeiSum1, invWeiSum2
222 516 : CHECK_ASSERTION(__LINE__, all(0 <= weight1), SK_"@setDisKolm(): The condition `all(0 <= weight1)` must hold. weight1 = "//getStr(sample1))
223 80 : CHECK_ASSERTION(__LINE__, isAscending(sample1), SK_"@setDisKolm(): The condition `isAscending(sample1)` must hold. sample1 = "//getStr(sample1))
224 80 : CHECK_ASSERTION(__LINE__, isAscending(sample2), SK_"@setDisKolm(): The condition `isAscending(sample2)` must hold. sample2 = "//getStr(sample2))
225 1112 : CHECK_ASSERTION(__LINE__, abs(weisum1 - sum(weight1)) < 100 * epsilon(0._TKC), SK_"@setDisKolm(): The condition `weisum1 == sum(weight1)` must hold. weisum1, sum(weight1) = "//getStr([weisum1, sum(weight1)]))
226 240 : CHECK_ASSERTION(__LINE__, size(sample1, 1, IK) == size(weight1, 1, IK), SK_"@setDisKolm(): The condition `size(sample1) == size(weight1)` must hold. size(sample1), size(weight1) = "//getStr([size(sample1, 1, IK), size(weight1, 1, IK)]))
227 : nsam1 = size(sample1, 1, IK)
228 80 : nsam2 = size(sample2, 1, IK)
229 80 : if (0 < weisum1) invWeiSum1 = 1._TKC / weisum1
230 80 : if (0 < nsam2) invWeiSum2 = 1._TKC / nsam2
231 80 : disKolm = 0._TKC
232 0 : cdf1 = 0._TKC
233 0 : cdf2 = 0._TKC
234 : isam1 = 1_IK
235 : isam2 = 1_IK
236 658 : do
237 738 : if (nsam1 < isam1 .or. nsam2 < isam2) exit
238 658 : ell1 = sample1(isam1)
239 658 : ell2 = sample2(isam2)
240 658 : if (ell1 <= ell2) then
241 328 : cdf1 = cdf1 + weight1(isam1) * invWeiSum1
242 328 : isam1 = isam1 + 1_IK
243 : end if
244 658 : if (ell2 <= ell1) then
245 330 : cdf2 = isam2 * invWeiSum2
246 330 : isam2 = isam2 + 1_IK
247 : end if
248 738 : disKolm = max(disKolm, abs(cdf2 - cdf1))
249 : end do
250 :
251 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252 : #elif getDisKolm_ENABLED && SSD_ENABLED && (WII_ENABLED | WRR_ENABLED)
253 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 :
255 120 : TYPE_OF_WEIGHT :: copyWeight1(size(weight1, 1, IK))
256 120 : TYPE_OF_WEIGHT :: copyWeight2(size(weight2, 1, IK))
257 120 : real(TKC) :: copySample1(size(sample1, 1, IK))
258 60 : real(TKC) :: copySample2(size(sample2, 1, IK))
259 378 : copySample1 = sample1
260 388 : copySample2 = sample2
261 378 : copyWeight1 = weight1
262 388 : copyWeight2 = weight2
263 60 : call setDisKolm(disKolm, copySample1, copyWeight1, weisum1, copySample2, copyWeight2, weisum2)
264 :
265 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 : #elif setDisKolm_ENABLED && SSD_ENABLED && (WII_ENABLED | WRR_ENABLED)
267 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268 :
269 160 : integer(IK) :: index1(size(sample1, 1, IK))
270 160 : integer(IK) :: index2(size(sample2, 1, IK))
271 80 : call setSorted(sample1, index1)
272 80 : call setSorted(sample2, index2)
273 1032 : sample1 = sample1(index1)
274 1052 : sample2 = sample2(index2)
275 1032 : weight1 = weight1(index1)
276 1052 : weight2 = weight2(index2)
277 80 : call setDisKolm(disKolm, sample1, weight1, weisum1, sample2, weight2, weisum2, ascending)
278 :
279 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 : #elif (getDisKolm_ENABLED || setDisKolm_ENABLED) && SSA_ENABLED && (WII_ENABLED | WRR_ENABLED)
281 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282 :
283 : real(TKC) :: cdf1, cdf2
284 : real(TKC) :: ell1, ell2
285 : integer(IK) :: isam1, isam2
286 : integer(IK) :: nsam1, nsam2
287 : real(TKC) :: invWeiSum1, invWeiSum2
288 516 : CHECK_ASSERTION(__LINE__, all(0 <= weight1), SK_"@setDisKolm(): The condition `all(0 <= weight1)` must hold. weight1 = "//getStr(sample1))
289 526 : CHECK_ASSERTION(__LINE__, all(0 <= weight2), SK_"@setDisKolm(): The condition `all(0 <= weight2)` must hold. weight2 = "//getStr(sample2))
290 80 : CHECK_ASSERTION(__LINE__, isAscending(sample1), SK_"@setDisKolm(): The condition `isAscending(sample1)` must hold. sample1 = "//getStr(sample1))
291 80 : CHECK_ASSERTION(__LINE__, isAscending(sample2), SK_"@setDisKolm(): The condition `isAscending(sample2)` must hold. sample2 = "//getStr(sample2))
292 1112 : CHECK_ASSERTION(__LINE__, abs(weisum1 - sum(weight1)) < 100 * epsilon(0._TKC), SK_"@setDisKolm(): The condition `weisum1 == sum(weight1)` must hold. weisum1, sum(weight1) = "//getStr([weisum1, sum(weight1)]))
293 1132 : CHECK_ASSERTION(__LINE__, abs(weisum2 - sum(weight2)) < 100 * epsilon(0._TKC), SK_"@setDisKolm(): The condition `weisum2 == sum(weight2)` must hold. weisum2, sum(weight2) = "//getStr([weisum2, sum(weight2)]))
294 240 : CHECK_ASSERTION(__LINE__, size(sample1, 1, IK) == size(weight1, 1, IK), SK_"@setDisKolm(): The condition `size(sample1) == size(weight1)` must hold. size(sample1), size(weight1) = "//getStr([size(sample1, 1, IK), size(weight1, 1, IK)]))
295 240 : CHECK_ASSERTION(__LINE__, size(sample2, 1, IK) == size(weight2, 1, IK), SK_"@setDisKolm(): The condition `size(sample2) == size(weight2)` must hold. size(sample2), size(weight2) = "//getStr([size(sample2, 1, IK), size(weight2, 1, IK)]))
296 : nsam1 = size(sample1, 1, IK)
297 : nsam2 = size(sample2, 1, IK)
298 80 : if (0 < weisum1) invWeiSum1 = 1._TKC / weisum1
299 80 : if (0 < weisum2) invWeiSum2 = 1._TKC / weisum2
300 80 : disKolm = 0._TKC
301 0 : cdf1 = 0._TKC
302 0 : cdf2 = 0._TKC
303 : isam1 = 1_IK
304 : isam2 = 1_IK
305 658 : do
306 738 : if (nsam1 < isam1 .or. nsam2 < isam2) exit
307 658 : ell1 = sample1(isam1)
308 658 : ell2 = sample2(isam2)
309 658 : if (ell1 <= ell2) then
310 328 : cdf1 = cdf1 + weight1(isam1) * invWeiSum1
311 328 : isam1 = isam1 + 1_IK
312 : end if
313 658 : if (ell2 <= ell1) then
314 330 : cdf2 = cdf2 + weight2(isam2) * invWeiSum2
315 330 : isam2 = isam2 + 1_IK
316 : end if
317 738 : disKolm = max(disKolm, abs(cdf2 - cdf1))
318 : end do
319 : #else
320 : !%%%%%%%%%%%%%%%%%%%%%%%%
321 : #error "Unrecognized interface."
322 : !%%%%%%%%%%%%%%%%%%%%%%%%
323 : #endif
324 : #undef TYPE_OF_WEIGHT
325 : #undef CDF_ARG
|