The Birthday Problem 2.0 for my Birthday

Author: 7000series

Posts

Total: 8
7000series
7000series's avatar
Debates: 22
Posts: 199
1
3
9
7000series's avatar
7000series
1
3
9
The Birthday Problem:

If I am partying in a room with 25 people; what is the chance that NO two of those people will share a birthday?
Another way to phrase this: When given 25 random people, what is the chance that for every day of the year, either one or zero of those people will have a birthday on that day.

The Birthday Solution:

For simplicity's sake, we will assume that all days of the year are equally likely to have birthdays fall on them.
For simplicity's sake, we will also ignore leap years, and thus leap days.

Since each person could have a birthday on any day of the year, in total there are 365 ^ 25 possibilities.
But how many of those 365 ^ 25 possibilities will satisfy the requirement that no two people may share a birthday?
You can think of it like this: Person-A has 356 days to choose from. Person-B only has 364 days to choose from without conflicting with person-A's choice. Person-C has 363 choices, and so on and so forth.
Right now we have two numbers: 365 * 364 * 363 . . . * 343 * 342 * 341 simplifies to 365! / 340! which is the number of possibilities that work, and 365 ^ 25 is the total number of possibilities.
By using division, and then multiplying by 100, we come to a percentage: 43.18%

The Birthday Problem 2.0:

Because everybody likes me, I am partying in a room with 170 people; what is the chance that NO four people will share a birthday?
Another way to phrase this: When given 170 random people, What is the chance that for every day of the year,  no more than three of those people will have a birthday on that day.

The Birthday Solution 2.0:

I was going to try to explain my program, but I am not that good at explaining things, so here is the C code.
int stopfact( int pier, int depth ) { int retval = 1; for( int i = 0; i < depth; ++i ) { retval *= pier; --pier; } return retval;}double power( double base, int exponent ) { double retval = 1.0; for( int i = 0; i < exponent; ++i ) { retval *= base; } return retval;}#include <stdio.h>#include <stdlib.h>int main() { int bucket_count = 0; double * buckets; double chance_total = 0.0; int copies; double frequency; while( scanf( "%i %lf", & copies, & frequency ) == 2 ) { buckets = realloc( buckets, sizeof( double ) * ( bucket_count + copies ) ); for( int i = 0; i < copies; ++i ) { buckets[ bucket_count ] = frequency; ++bucket_count; chance_total += frequency; } } int balls; int limit; double * chancetable; double * newtable; scanf( "?> %i %i", & balls, & limit ); chancetable = malloc( sizeof( double ) * ( balls + 1 ) ); newtable = malloc( sizeof( double ) * ( balls + 1 ) ); chancetable[ 0 ] = 1.0; for( int i = 1; i <= balls; ++i ) { chancetable[ i ] = 0.0; } for( int i = 0; i < bucket_count; ++i ) { for( int u = 0; u <= balls; ++u ) { newtable[ u ] = 0.0; } for( int u = 0; u < limit; ++u ) { for( int z = 0; z + u <= balls; ++z ) { newtable[ z + u ] += chancetable[ z ] * ( double )( stopfact( balls - z, u ) / stopfact( u, u ) ) * power( buckets[ i ] / chance_total, u ) * power( ( chance_total - buckets[ i ] ) / chance_total, ( balls - z ) - u ); } } for( int u = 0; u <= balls; ++u ) { chancetable[ u ] = newtable[ u ]; } chance_total -= buckets[ i ]; } printf( "%lf %\n", chancetable[ balls ] * 100.0 ); free( buckets ); free( chancetable ); return 0;}
To see the answer for yourself, run the program and input the following:
365   4
1   1
?>   170   4
If you made sure to space separate, the result should be: 61.30% accounting for leap years too.
7000series
7000series's avatar
Debates: 22
Posts: 199
1
3
9
7000series's avatar
7000series
1
3
9
-->
@ebuc
You might have something useful to say here?
n8nrgim
n8nrgim's avatar
Debates: 0
Posts: 1,183
3
2
5
n8nrgim's avatar
n8nrgim
3
2
5
I've heard of the issue and I can't wrap my mind around it at all, and I even got all As in my college math classes even through advanced math and graduate statistics. 
n8nrgim
n8nrgim's avatar
Debates: 0
Posts: 1,183
3
2
5
n8nrgim's avatar
n8nrgim
3
2
5
Here is a riddle that's also hard to wrap your mind around 
WyIted
WyIted's avatar
Debates: 34
Posts: 7,667
3
4
9
WyIted's avatar
WyIted
3
4
9
Some birthdays are more common than others. In a room of 23 people there is about a 50% chance of two people sharing a birthday.
WyIted
WyIted's avatar
Debates: 34
Posts: 7,667
3
4
9
WyIted's avatar
WyIted
3
4
9
If 23 people is 50% I am not sure of 25. I just know this is something I had to learn for a test or to help me understand the concept of hashes
7000series
7000series's avatar
Debates: 22
Posts: 199
1
3
9
7000series's avatar
7000series
1
3
9
Wylted, please elaborate. I know that there is such thing as a 'birthday attack' for password hashes, but I don't remember much.
7000series
7000series's avatar
Debates: 22
Posts: 199
1
3
9
7000series's avatar
7000series
1
3
9
Also, if you had actually read my explanation, you would have known that in a room of 25 people, there is a 43.18 percent chance of having no overlapping birthdays.