File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
spec/ruby/core/array/fixtures Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -61,18 +61,23 @@ def self.empty_recursive_array
61
61
def self . measure_sample_fairness ( size , samples , iters )
62
62
ary = Array . new ( size ) { |x | x }
63
63
( samples ) . times do |i |
64
- counts = Array . new ( size ) { 0 }
65
- expected = iters / size
66
- iters . times do
67
- x = ary . sample ( samples ) [ i ]
68
- counts [ x ] += 1
69
- end
70
- chi_squared = 0.0
71
- counts . each do |count |
72
- chi_squared += ( ( ( count - expected ) ** 2 ) * 1.0 / expected )
64
+ chi_results = [ ]
65
+ 3 . times do
66
+ counts = Array . new ( size ) { 0 }
67
+ expected = iters / size
68
+ iters . times do
69
+ x = ary . sample ( samples ) [ i ]
70
+ counts [ x ] += 1
71
+ end
72
+ chi_squared = 0.0
73
+ counts . each do |count |
74
+ chi_squared += ( ( ( count - expected ) ** 2 ) * 1.0 / expected )
75
+ end
76
+ chi_results << chi_squared
77
+ break if chi_squared <= CHI_SQUARED_CRITICAL_VALUES [ size ]
73
78
end
74
79
75
- chi_squared . should <= CHI_SQUARED_CRITICAL_VALUES [ size ]
80
+ chi_results . min . should <= CHI_SQUARED_CRITICAL_VALUES [ size ]
76
81
end
77
82
end
78
83
You can’t perform that action at this time.
0 commit comments