ML Interview Q Series: Validating Unfair Dice Distributions with Probability Axioms
Browse all the Probability Interview Questions here.
In order to describe an unfair die properly, we must specify the probability for each of the six possible outcomes. The following table gives answers for each of 4 different dice. Which of the four dice have validly specified probabilities and which do not? In the case of an invalidly described die, explain why the probabilities are invalid.
Short Compact solution
Die 1 is valid.
Die 2 is invalid. The probabilities do not sum to 1; in fact, they sum to 41/42.
Die 3 is valid.
Die 4 is invalid. Two of the probabilities are negative.
Comprehensive Explanation
The Requirements for a Valid Probability Distribution
To determine whether a die’s probability distribution is valid, two fundamental conditions must be met:
All probabilities must be nonnegative.
The probabilities must sum exactly to 1.
In mathematical form, for a single die with outcomes 1 through 6, we require:
where p(i) is the probability of rolling the face i. Furthermore, each probability p(i) must be greater than or equal to 0 for all i from 1 to 6.
Below is a detailed check for each die:
Die 1 Analysis
Probabilities: 1/3, 0, 1/6, 0, 1/6, 1/3
Nonnegativity: All the given probabilities are 0 or positive (1/3, 0, 1/6, 1/6, etc.). Hence no violation here.
Sum to 1: 1/3 + 0 + 1/6 + 0 + 1/6 + 1/3 = 1/3 + 1/6 + 1/6 + 1/3 = 2/6 + 1/6 + 1/6 + 2/6 = (2 + 1 + 1 + 2)/6 = 6/6 = 1 Hence the total is exactly 1.
Therefore, Die 1 is valid.
Die 2 Analysis
Probabilities: 1/6, 1/6, 1/6, 1/6, 1/6, 1/7
Nonnegativity: All entries are nonnegative, so that condition is satisfied.
Sum to 1: Summing the first five probabilities each equal to 1/6 gives 5 * (1/6) = 5/6. Then we have an additional 1/7 for the sixth face. So total sum = 5/6 + 1/7.
Converting to a common denominator 42, 5/6 = 35/42, and 1/7 = 6/42, so the sum is 41/42, which is not equal to 1.
Thus, Die 2 is invalid because its probabilities do not sum to 1.
Die 3 Analysis
Probabilities: 1/7, 1/7, 1/7, 1/7, 1/7, 2/7
Nonnegativity: All probabilities are nonnegative.
Sum to 1: 1/7 + 1/7 + 1/7 + 1/7 + 1/7 + 2/7 = (1 + 1 + 1 + 1 + 1 + 2)/7 = 7/7 = 1
Therefore, Die 3 is valid.
Die 4 Analysis
Probabilities: 1/3, 1/3, -1/6, -1/6, 1/3, 1/3
Nonnegativity: Two probabilities are negative (-1/6), which directly violates the nonnegativity requirement.
Sum to 1: Even before checking the sum, the presence of negative probabilities makes this distribution invalid.
Hence, Die 4 is invalid because it assigns negative probabilities to outcomes.
Follow-up question 1: What if the sum of probabilities is 0.999999 instead of exactly 1 due to floating-point imprecision?
In practical computational scenarios, floating-point imprecision often leads to sums that are very close to, but not exactly, 1. In real-world applications—especially in machine learning or simulation—small deviations like 0.999999 or 1.000001 are often tolerated as floating-point artifacts. Generally, if the discrepancy is within an acceptable tolerance (e.g., less than 1e-6), we consider it acceptable and may normalize the probabilities by dividing each probability by the sum to ensure they exactly sum to 1.
However, in a strictly mathematical context or in symbolic calculations, the probability distribution must sum exactly to 1. In software, mild deviations are usually handled by a normalization step to fix any minor floating-point issues.
Follow-up question 2: Can an “unfair” die still have probabilities that match a fair distribution?
Yes. The term “unfair” typically means the die does not have all faces equally likely. However, one can conceptually label a die “unfair” even if it coincidentally matches the uniform distribution. For instance, someone might produce an “unfair” die intending to bias certain faces, but after measurement it turns out the probabilities are all 1/6. The classification “unfair” is about the process or design rather than the final numerical distribution. Mathematically, if all faces end up with probability 1/6, that is effectively the same as a fair distribution—even if the die was not constructed to be fair.
Follow-up question 3: Why is nonnegativity important in probability, and could there be any extension that allows “negative probabilities”?
Nonnegativity is fundamental for standard probability theory, since a probability must reflect a measure of likelihood in [0,1]. If p(i) < 0 for any event i, it becomes impossible to interpret that as a real-world likelihood.
“Negative probabilities” do appear in certain advanced contexts—e.g., in quantum field theories or certain quasi-probability distributions (like the Wigner function)—but those scenarios involve specialized mathematical frameworks, not standard probability for everyday statistical or machine learning tasks. In typical data science, negative probabilities have no physical interpretation and are disallowed.
Follow-up question 4: How can I simulate these unfair dice in a coding environment like Python?
If we assume we have a valid array of probabilities p = [p1, p2, p3, p4, p5, p6] that sum to 1 and are all >= 0, we can do the following in Python:
import random
def roll_unfair_die(probabilities):
"""
probabilities should be a list or tuple of length 6,
with each probability >= 0 and sum of them = 1.
Returns an integer from 1 to 6 based on these probabilities.
"""
r = random.random() # Uniform random float in [0,1)
cumulative = 0.0
for i, p in enumerate(probabilities, start=1):
cumulative += p
if r < cumulative:
return i
Internally, this code segments the range [0,1) according to the given probabilities and returns the face whose segment contains the random sample. You could then call roll_unfair_die([1/3, 0, 1/6, 0, 1/6, 1/3])
for Die 1, or the corresponding probabilities for Die 3, etc.
This approach ensures the outcome distribution matches the intended probabilities.
By addressing all these details—correct sum of probabilities, nonnegative values, practical floating-point concerns, and real-world implementation—one can confidently handle these dice validity checks and use them in typical machine learning or simulation workflows.