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

Function CheckSkewed

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

Source from the content-addressed store, hash-verified

201}
202
203static void CheckSkewed(SimplePhilox* rnd, WeightedPicker* picker, int trials) {
204 const int size = picker->num_elements();
205 int* count = new int[size];
206 memset(count, 0, sizeof(count[0]) * size);
207 for (int i = 0; i < size * trials; i++) {
208 const int elem = picker->Pick(rnd);
209 EXPECT_GE(elem, 0);
210 EXPECT_LT(elem, size);
211 count[elem]++;
212 }
213
214 for (int i = 0; i < size - 1; i++) {
215 LOG(INFO) << i << ": " << count[i];
216 const float ratio = float(count[i + 1]) / float(count[i]);
217 EXPECT_GE(ratio, 1.6f);
218 EXPECT_LE(ratio, 2.4f);
219 }
220 delete[] count;
221}
222
223static void TestPickAt(int items, const int32* weights) {
224 WeightedPicker picker(items);

Callers 1

TestPickerFunction · 0.85

Calls 2

PickMethod · 0.80
num_elementsMethod · 0.45

Tested by

no test coverage detected