4 #include <cds/Vector.h>
7 // Auxiliary to perform K-S test for a given flag, sample size and bins count
8 void aux_ks_test(int flag
, uint32_t N
, uint32_t nBins
)
14 for (uint32_t i
=0; i
<nBins
; i
++)
16 for (uint32_t i
=0; i
<N
; i
++)
18 Real rf
= get_rand_real();
19 uint32_t index
= floor(rf
*nBins
);
20 if (index
>= nBins
) index
= nBins
- 1; //in case of...
25 double ksThreshold
= 1.358 / sqrt((double)N
);
26 double countPerBin
= (double)N
/ nBins
;
27 uint32_t cumulativeSum
= 0;
28 for (uint32_t i
=0; i
<nBins
; i
++)
30 cumulativeSum
+= bins
[i
];
31 LUT_ASSERT((double)cumulativeSum
/ N
- (i
+1)*countPerBin
/N
< ksThreshold
);
35 // Kolmogorov-Smirnov test on random real numbers (flag==0)
38 aux_ks_test(0, 1000000, 1000);
39 aux_ks_test(0, 100000, 1000);
40 aux_ks_test(0, 10000, 100);
43 // Kolmogorov-Smirnov test on random real numbers (flag==1)
46 aux_ks_test(1, 1000000, 1000);
47 aux_ks_test(1, 100000, 1000);
48 aux_ks_test(1, 10000, 100);