How long should a random id be to avoid collisions

Back to list2025-05-22
You

How long should a random id be to avoid collisions?

ChatGPT

Use the birthday approximation: collisions become likely around \(\sqrt{N}\) draws from a space of size \(N\). For a 64-bit id that is about 4 billion items, for 128 bits it is beyond anything you will generate. The practical answer for most systems is 128 random bits and no coordination.

You

A test is 99% accurate and I tested positive. Am I 99% likely to be ill?

ChatGPT

No, and the gap is the whole point of the rule:

\[P(D \mid +) = \frac{P(+ \mid D)\,P(D)}{P(+ \mid D)P(D) + P(+ \mid \lnot D)P(\lnot D)}\]

With a prevalence \(P(D) = 0.001\) and both error rates at 1%, this gives roughly \(0.09\). Nine percent, not ninety-nine, because false positives are drawn from a pool a thousand times larger.