MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CheckUniform

Function CheckUniform

tensorflow/core/lib/random/weighted_picker_test.cc:183–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183static void CheckUniform(SimplePhilox* rnd, WeightedPicker* picker,
184 int trials) {
185 const int size = picker->num_elements();
186 int* count = new int[size];
187 memset(count, 0, sizeof(count[0]) * size);
188 for (int i = 0; i < size * trials; i++) {
189 const int elem = picker->Pick(rnd);
190 EXPECT_GE(elem, 0);
191 EXPECT_LT(elem, size);
192 count[elem]++;
193 }
194 const int expected_min = int(0.9 * trials);
195 const int expected_max = int(1.1 * trials);
196 for (int i = 0; i < size; i++) {
197 EXPECT_GE(count[i], expected_min);
198 EXPECT_LE(count[i], expected_max);
199 }
200 delete[] count;
201}
202
203static void CheckSkewed(SimplePhilox* rnd, WeightedPicker* picker, int trials) {
204 const int size = picker->num_elements();

Callers 2

TESTFunction · 0.85
TestPickerFunction · 0.85

Calls 2

PickMethod · 0.80
num_elementsMethod · 0.45

Tested by

no test coverage detected