c ++随机引擎不是真正随机的

Gui*_*gue 3 c++ random c++11

我正在玩c ++随机引擎,让我感到不安.注意到我的值大致相同,我做了以下测试:

#include <random>
#include <functional>
#include <iostream>

int main()
{
    auto res = std::random_device()();
    std::ranlux24 generator(res);
    std::uniform_int_distribution<uint32_t> distribution;
    auto roll = std::bind(distribution, generator);


    for(int j = 0; j < 30; ++j)
    { 
        double ssum = 0;
        for(int i = 0; i< 300; ++i)
        {
            ssum += std::log10(roll());
        }
        std::cout << ssum / 300. << std::endl;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

无论我使用什么引擎,我打印的值都是9.2,看起来更像是正态分布.有没有我没有正确理解的东西?谢谢你,纪尧姆

Ben*_*ley 14

注意到我的价值大致相同

这正是您对均匀随机数生成器的期望.在[10 ^(n-1),10 ^ n)范围内有9倍的整数,因为在[0,10 ^(n-1))范围内.