ThreadLocalRandom() 随机数分布问题 - sample_neighbor_layerwise OP
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 553
- PR merge metrics
- No merged PRs in 30d
Description
在对 **sample_neighbor_layerwise** OP测试的时候,发现最终结果和预期存在出入。定位到是 DAG流程中 **API_SAMPLE_L,3** 中采样邻居的输出节点分布不符合预期。以下是具体结果和复现方法:
- 测试graph:
`base.initialize_graph({
'mode': 'local',
'data_path': '/tmp/euler',
'sampler_type': 'all',
'data_type': 'all'
})`
- 调用函数:
`sample_neighbor_layerwise([[1, 2, 3]], ['0', '1'], 10, -1, '')`(循环执行10000次)
- 输出Log打点方法(euler/common/compact_weighted_collection.h):
在执行过程中,只会涉及到3个点(nodeId 1、nodeId 2、nodeId 3),而每个点在采样邻居时先采样边类型、再采样点。根据它们各自的权重列表不同,分为了6种情形,分别统计每种情形下的随机数情况。

- 统计结果:
将6种情形下各自的随机数落在每个区间的频率情况作了统计。

- 问题:
观察统计结果,在6种情形下,随机数的区间频数分布并不均匀,甚至出现了频数为0的区间,似乎违背了ThreadLocalRandom()的产生均匀随机数的初衷。请问该结果是否合理呢?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with sample_neighbor_layerwise and euler/common/compact_weighted_collection.h, then reproduce the 10,000-call experiment described in the issue. Compare the six weight-list cases and determine whether the observed zero-frequency bins are expected; done means documenting the cause and confirming the conclusion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100