Birthday paradox problem is to fill a room with n people and get the probability of at least 2 people having the same b'day. This is given for 25 people as 1-(364.363.362....341)/(365^24). This can be done using the following snippet in C++.
http://en.wikipedia.org/wiki/Birthday_problem#Calculating_the_probability
void bDayParadox() {
float result = 1.0;
int numerator = 364.0;
for (int i = 0; i < 24; i++) {
result = result * (numerator / 365.0);
numerator = numerator - 1.0;
}
std::cout << 1.0-result << std::endl;
}
http://en.wikipedia.org/wiki/Birthday_problem#Calculating_the_probability
void bDayParadox() {
float result = 1.0;
int numerator = 364.0;
for (int i = 0; i < 24; i++) {
result = result * (numerator / 365.0);
numerator = numerator - 1.0;
}
std::cout << 1.0-result << std::endl;
}
Comments
Post a Comment