Questions tagged [birthday-paradox]

The Birthday Paradox is a phenomenon in probability in which the probability of a population containing two individuals with the same property is much greater than would be intuitively expected. In its original form it describes the likelihood that any two individuals in a room share a birthday. Amongst other things, the Birthday Paradox affects cryptography, hashing and various applications of random number generators.

The Birthday Paradox is a phenomenon where two individual samples selected from a population may have the same value, for example the birthdays of individuals in a room. The paradox is that the probability of this coincidence happening is much higher than people expect. Amongst other things the phenomenon affects hashing, cryptography and various applications of random number generators.

Overview

The problem is originally defined as the probability of any two people in the room sharing the same birthday. The key point is that any two people in the room could share a birthday. People tend to naively misinterpret the problem as the probability of someone in the room sharing a birthday with a specific individual, which is the source of the cognitive bias that often causes people to underestimate the probability. This is the incorrect assumption – there is no requirement for the match to be to a specific individual and any two individuals could match.

This graph shows the probability of a shared birthday as number of people in the room increases. For 23 people, the probability of two sharing a birthday is just over 50%.

The probability of a match occurring between any two individuals is much higher than the probability of a match to a specific individual as the match does not have to be to a specific date. Rather, you only have to find two individuals that share the same birthday. From this graph (which can be found on the wikipedia page on the subject), we can see that we only need 23 people in the room for there to be a 50% chance of finding two that match in this way.

Some applications

  • Cryptographic hashing relies on the low probability of any two items having the same hash value. In order to achieve this the hash value must be very large so as to make it computationally infeasible to find another item that hashes to the same value. The Birthday paradox means that the width of the hash values must be very large in order for the probability of a collision to be sufficiently low.

  • In a Hash Table, the Birthday Paradox makes the likelihood of collisions quite high unless you have a perfect hash function that hashes a controlled set of source values to a unique set of hash values. In other cases, the hash table must be able to deal with relatively frequent collisions.

  • If you need a guaranteed unique sequence of random numbers, you cannot rely on simply generating random numbers, as the probability of a collision is quite high for relatively small sample sets. Instead, a set of unique numbers must be generated (perhaps just sequentially) and shuffled into a random order.

The tag is most applicable to questions about applications directly affected by the phenomenon (e.g. cryptographic hashing), or perhaps re-tagging a question where the poster has displayed obvious naievity about it.

57 questions
0
votes
2 answers

Birthday paradox

I want to simulate the birthday paradox in java. For some reason my output(probability) keeps getting very close to 1 e.g. simulation(10)->0,9268. In start you can see the probabilities my simulations should be close to. I have been looking for a…
Marnix
  • 3
  • 3
0
votes
1 answer

Hashing Birthday Paradox

So I am working on a piece of code that computes the hashes of 2^4 sets of 3 random prime numbers (less than 2^8). Then keep selecting sets of 3 composite numbers (less than 2^8) until there is a set of {c1, c2, c3} with a hash value that matches…
LifeofBob
  • 37
  • 6
0
votes
1 answer

Find duplicate birthday (Java)

The code is to run simulations to find out the probability of n people sharing the same birthday. I compared randomly assigned birthdates to an array of dates. For any dates that has more than 1 equal value, I added one to the numerator. However,…
coder1234
  • 11
  • 2
0
votes
1 answer

Can i safely take the head of an uuidv4 to arrive at the collision/space-consumption tradeoff I want?

I'm wondering if I can safely calculate the chances of collision using the birthday-paradox, by taking a variable head (i.e.: the x first characters) of an uuidv4. usecase: I want random id's with small chances for collision. However, the number of…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
0
votes
2 answers

How to do the Birthday Paradox looping

I have to do the birthday paradox program as an assignment for school. I got the program to run but seem to hav trouble getting the correct answer. I think it's a problem with my loops in the check_birthdays function. Here's the code: #include…
-1
votes
1 answer

Birthday Paradox count keeps growing in python

I need this code to output the total count of matching birthdays, but the count keeps growing and I don't know why. We should expect to see a total approx. half the amount of the simulations. I have it appending to a list at the moment to visualize…
Azra P
  • 1
  • 3
-1
votes
2 answers

Java: Birthday paradox

I'm trying to make a program that represents the birthday paradox. I understand the paradox and I'm pretty sure my code is wrong but I'm not sure where I went wrong. I've looked through related posts, but I haven't found anything that's helpful. …
Hades948
  • 21
  • 6
-1
votes
1 answer

Partial collision for Reduced SHA1 hash

i am doing a project to find two different sentence which give partial collision based on reduced sha1 hashing. My program will generate two different message. If the first 32bit of the hashing of the two sentence matches, the program will stop else…
Happy
  • 29
  • 6
-1
votes
2 answers

What does year = [0]*365 mean in this Python code?

I tried to write a function of 'The Birthday Paradox'. I found some examples in the internet and succseed in combining everything together with some modification but still there are things that I don't understand in my program. This is my program:…
Netta
  • 63
  • 8
-1
votes
1 answer

C++ Birthday Paradox Program

I am trying to figure out the Birthday Paradox program for my C++ class. This is what I have so far, but it's not working. I tried looking through other questions about the same topic on here but I'm still pretty lost so any help would be greatly…
-2
votes
2 answers

birthday paradox fastest search

The birthday problem or birthday paradox predicts the likelihood of one or more matching birthdays in a group of N people. Several sites explain how it works, and the mathematics behind…
-3
votes
1 answer

Some questions about bday paradox results

I need someone to correct me or to discuss with me, why are my results of a 23 person calculation of the bday paradox always ~65%. It is said it should be ~50%, but whatever I do, I receive this result. What I ask is someone to explain to me what I…
VirusWar
  • 7
  • 5
1 2 3
4