MCPcopy Create free account
hub / github.com/dmlc/xgboost / GenerateRandom

Function GenerateRandom

tests/cpp/common/test_hist_util.h:30–41  ·  view source on GitHub ↗

Generate columns with different ranges

Source from the content-addressed store, hash-verified

28namespace xgboost::common {
29// Generate columns with different ranges
30inline std::vector<float> GenerateRandom(int num_rows, int num_columns) {
31 std::vector<float> x(num_rows * num_columns);
32 std::mt19937 rng(0);
33 std::uniform_real_distribution<float> dist(0.0, 1.0);
34 std::generate(x.begin(), x.end(), [&]() { return dist(rng); });
35 for (auto i = 0; i < num_columns; i++) {
36 for (auto j = 0; j < num_rows; j++) {
37 x[j * num_columns + i] += i;
38 }
39 }
40 return x;
41}
42
43inline std::vector<float> GenerateRandomWeights(int num_rows) {
44 std::vector<float> w(num_rows);

Callers 1

TESTFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected