// bernoulli_distribution
#include <iostream>
#include <random>
int main()
{
const int nrolls=10000;
std::default_random_engine generator;
std::bernoulli_distribution distribution(0.95);
int count=0; // count number of trues
for (int i=0; i<nrolls; ++i) if (distribution(generator)) ++count;
std::cout << "bernoulli_distribution (0.95) x 10000:" << std::endl;
std::cout << "true: " << count << std::endl;
std::cout << "false: " << nrolls-count << std::endl;
return 0;
}
Ly8gYmVybm91bGxpX2Rpc3RyaWJ1dGlvbgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxyYW5kb20+CgppbnQgbWFpbigpCnsKICBjb25zdCBpbnQgbnJvbGxzPTEwMDAwOwoKICBzdGQ6OmRlZmF1bHRfcmFuZG9tX2VuZ2luZSBnZW5lcmF0b3I7CiAgc3RkOjpiZXJub3VsbGlfZGlzdHJpYnV0aW9uIGRpc3RyaWJ1dGlvbigwLjk1KTsKCiAgaW50IGNvdW50PTA7ICAvLyBjb3VudCBudW1iZXIgb2YgdHJ1ZXMKCiAgZm9yIChpbnQgaT0wOyBpPG5yb2xsczsgKytpKSBpZiAoZGlzdHJpYnV0aW9uKGdlbmVyYXRvcikpICsrY291bnQ7CgogIHN0ZDo6Y291dCA8PCAiYmVybm91bGxpX2Rpc3RyaWJ1dGlvbiAoMC45NSkgeCAxMDAwMDoiIDw8IHN0ZDo6ZW5kbDsKICBzdGQ6OmNvdXQgPDwgInRydWU6ICAiIDw8IGNvdW50IDw8IHN0ZDo6ZW5kbDsKICBzdGQ6OmNvdXQgPDwgImZhbHNlOiAiIDw8IG5yb2xscy1jb3VudCA8PCBzdGQ6OmVuZGw7CgogIHJldHVybiAwOwp9