random_device::entropy
乱数発生源の無作為性を推定します。
double entropy() const;
解説
このメンバー関数は、乱数発生源がどの程度の無作為性を持っているかの推定値を返します。評価の単位には、ビットが使用されます。極端な例でいうと、無作為性がまったくない場合、エントロピ (無作為性の程度) はゼロになります。
使用例
// std_tr1__random__random_device_entropy.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::random_device Myceng;
int main()
{
Myceng ceng;
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
std::cout << "entropy == " << ceng.entropy() << std::endl;
std::cout << "min == " << ceng.min() << std::endl;
std::cout << "max == " << ceng.max() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
return (0);
}
必要条件
ヘッダー : <random>
名前空間: std