testsAndMisc/CPP/miscelanious/yousuckatcards/Bernouli/bernouli.cpp
Krzysztof kuhy Rudnicki e3f9e6dc0b fix: correct shebang and executable permissions
- Add +x to Python scripts with shebangs (3 files)
- Remove -x from non-script files like .cpp, .txt, makefile (23 files)
- Move shebang to first line in C/imageViewer/lint.sh
2025-11-30 13:42:16 +01:00

23 lines
489 B
C++

// bernoulli_distribution
#include <iostream>
#include <random>
int main()
{
const int nrolls=10000;
std::random_device rd;
std::mt19937 gen(rd());
std::bernoulli_distribution distribution(0.5);
int count=0; // count number of trues
for (int i=0; i<nrolls; ++i) if (distribution(gen)) ++count;
std::cout << "bernoulli_distribution (0.5) x 10000:" << std::endl;
std::cout << "true: " << count << std::endl;
std::cout << "false: " << nrolls-count << std::endl;
return 0;
}