File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -233,13 +233,18 @@ RandomTests.test("different random number generators") {
233233func chi2Test( _ samples: [ Double ] ) -> Bool {
234234 precondition ( samples. count == 50 , " confidence interval requires 50 samples " )
235235 let expected = samples. reduce ( 0 , + ) / Double( samples. count)
236- let cvLow = 23.983 // 0.1% with a degree of freedom of (50 - 1)
237- let cvHigh = 85.351 // 99.9% with a degree of freedom of (50 - 1)
236+ // Right tail for 0.0001% (1e-6) with a degree of freedom of (50 -
237+ // 1). With hundreds of builds a day, this has to be very low to not get too
238+ // many spurious failures, but obvious problems should still be detected
239+ // (e.g. an off-by-one that means samples[0] == 0 will result in chi2 =
240+ // (0-expected)**2/expected + ... > expected, so as long as we've generated
241+ // more than samples.count * cvHigh (~5500) values, we'll catch it).
242+ let cvHigh = 111.1
238243 let chi2 = samples. map {
239244 ( ( $0 - expected) * ( $0 - expected) ) / expected
240245 } . reduce ( 0 , + )
241246
242- if chi2 < cvLow || chi2 > cvHigh {
247+ if chi2 > cvHigh {
243248 return false
244249 } else {
245250 return true
You can’t perform that action at this time.
0 commit comments