The log2 stuff is really just asking: How many bits are there in the number when written in binary? That's the key factor when you're trying to figure the probability of getting the same value in a set twice.

The birthday problem is this: Every time you walk into a bar with at least X people in it, you bet the bartender that there are at least 2 people in the bar with the same birthday. How big does X have to be so that you will win more often than you lose? The answer is just 23, which surprises most people because it's a lot lower than you might suspect. But if you never make this bet when there are fewer than 23 people in the bar, and you always make this bet when there are more than 23, then you will make money. Unless, of course, the bartender knows everybody's birthday and doesn't take the bet when he would lose! ;-)

The bits come into it because there's an easy way to get an approximate answer just by taking the number of bits that you need to represent the number of choices, divide that number of bits by 2, and raise 2 to that power. The larger the numbers you're dealing with, the better this is as an approximation. (It's actually not very good an approximation for a number as low as 365. You get 19 this way, which will cause you to lose money!)

The log2 comes in because that's how you define the number of bits when your number of choices isn't a power of 2. E.g., for 365, the Log2 is 8.51, so that's how many "bits" you are dealing with.

Anyhow, if there really won't ever be more than 10,000 of these codes, you're probably okay.

The log2 stuff is really just asking: How many bits are there in the number when written in binary? That's the key factor when you're trying to figure the probability of getting the same value in a set twice.

The birthday problem is this: Every time you walk into a bar with at least X people in it, you bet the bartender that there are at least 2 people in the bar with the same birthday. How big does X have to be so that you will win more often than you lose? The answer is just 23, which surprises most people because it's a lot lower than you might suspect. But if you never make this bet when there are fewer than 23 people in the bar, and you always make this bet when there are more than 23, then you will make money. Unless, of course, the bartender knows everybody's birthday and doesn't take the bet when he would lose! ;-)

The bits come into it because there's an easy way to get an approximate answer just by taking the number of bits that you need to represent the number of choices, divide that number of bits by 2, and raise 2 to that power. The larger the numbers you're dealing with, the better this is as an approximation. (It's actually not very good an approximation for a number as low as 365. You get 19 this way, which will cause you to lose money!)

The log2 comes in because that's how you define the number of bits when your number of choices isn't a power of 2. E.g., for 365, the Log2 is 8.51, so that's how many "bits" you are dealing with.

Anyhow, if there really won't ever be more than 10,000 of these codes, you're probably okay.