- Learn
- Mathematics
- University Math
- Discrete Mathematics
- Discrete Probability
Discrete Probability
BeginnerLesson 9 of 10 in Discrete Mathematics Course
What you will learn
- Describe a random experiment by its outcomes, events and probability function, then calculate event probabilities with the basic rules and with counting.
- Set up a sample space and assign probabilitiesIdentify the outcomes of an experiment, write events as sets of outcomes, and check that a probability function is valid, for equally likely and for countably infinite sample spaces.
- Combine events with the rules of probabilityUse the complement rule, the addition rule and inclusion–exclusion to find probabilities of combined events, and bound the probability of a union with the union bound.
- Count equally likely outcomes to find probabilitiesCompute probabilities in uniform sample spaces with permutations and combinations, including card hands, sampling with and without replacement, and the birthday problem.
- Set up a sample space and assign probabilities
- Update probabilities when new information arrives, decide whether events are independent, and reverse a conditional probability with Bayes' theorem.
- Calculate and interpret conditional probabilitiesCompute the probability of an event given another, build products along a tree with the multiplication rule, and split a problem into cases with the law of total probability.
- Decide whether events are independentTest events for independence with the product rule, tell independence apart from disjointness, and use mutual independence for repeated trials.
- Update beliefs with Bayes' theoremUse Bayes' theorem with the law of total probability to turn the probability of evidence given a cause into the probability of the cause given the evidence, as in medical tests and spam filters.
- Calculate and interpret conditional probabilities
- Represent numerical results of experiments as random variables, describe them by their distributions, and recognize the uniform, Bernoulli, binomial and geometric distributions.
- Define random variables and their distributionsTreat a random variable as a function on the sample space, find its probability mass function and cumulative distribution function, and decide whether two random variables are independent.
- Recognize and use common discrete distributionsChoose and apply the uniform, Bernoulli, binomial and geometric distributions, checking the conditions each one needs.
- Define random variables and their distributions
- Calculate and interpret the expected value of a discrete random variable, and find expectations of counts quickly with linearity of expectation and indicator variables.
- Calculate and interpret expected valuesCompute expected values from a distribution, of functions of a random variable and by conditioning, and interpret them as long-run averages.
- Use linearity of expectation and indicator variablesFind expected counts by writing a random variable as a sum of indicators, without working out its distribution, and know where linearity does and does not apply.
- Calculate and interpret expected values
- Quantify how far a random variable tends to fall from its mean, and bound the probability of large deviations with Markov's, Chebyshev's and Chernoff's inequalities.
- Calculate variance and standard deviationCompute variance and standard deviation, use the rules for shifted, scaled and summed random variables, and apply the standard results for common distributions.
- Bound the probability of large deviationsUse Markov's and Chebyshev's inequalities and the Chernoff bound to guarantee that large deviations are unlikely, check the conditions of each, and derive the weak law of large numbers.
- Calculate variance and standard deviation
- Analyze randomized algorithms, control their error probability, and use expectation, indicators and the probabilistic method to study algorithms and data structures.
- Analyze randomized algorithms and their errorDistinguish Las Vegas from Monte Carlo algorithms, reduce one-sided error by repetition, and bound running times and failure probabilities.
- Use expectation and indicators to analyze algorithms and data structuresDerive the expected number of comparisons in randomized quicksort, analyze collisions in hashing, and prove that objects exist with the probabilistic method.
- Analyze randomized algorithms and their error
Discrete Probability study guide
1Build a probability model
A probability calculation begins with a precise description of what can happen. Outcomes give the detail; events collect the outcomes that answer a question. You will assign probabilities, combine events, and use counting to calculate chances in card hands and repeated draws. The main modeling choice is how to describe one outcome: that choice controls both what you count and whether those outcomes are equally likely.
1.1 Describe outcomes and assign their probabilities
Start with one complete result
An experiment is a random process with a well-defined set of possible results. One complete result is an outcome. The sample space contains all outcomes: exactly one occurs on each run. For two die rolls, an outcome can be the ordered pair , meaning 2 first and 5 second. The reversed pair describes another outcome.
An event is a subset of the sample space. For one roll, the event “even” is . The event occurs when the outcome belongs to that set. The empty set is impossible; the whole sample space is certain.
Set notation describes combined events. The union means “A or B, or both”; the intersection means “A and B.” The complement means “not A,” and means “A but not B.” Disjoint events have no outcome in common.
Give each outcome a weight
A probability function assigns a nonnegative probability to each outcome, with total 1:
Thus every event probability lies between 0 and 1, with and . The notations and are also used for event probabilities.
For a finite sample space of equally likely outcomes, every outcome has probability , giving . A fair die supports this model. A loaded die requires different outcome weights.
Two independent fair dice give 36 equally likely ordered pairs. Six pairs have sum 7, so that event has probability . Only has sum 2, giving probability . The eleven possible sums are therefore not equally likely. Likewise, the unordered result “a 1 and a 2” collects two pairs, while “two 1s” collects only one.
Build a tree when the process has stages
Draw a branch for each possible next result and label it with its probability at that stage. A leaf represents a complete outcome. Multiply branch probabilities along a path to get its weight, then add the weights of leaves in the event. This separates two jobs that are easy to mix up: multiplying to describe one path and adding to collect alternative paths.
Allow infinitely many possible stopping times
Flip a fair coin until the first head. The terminating outcomes are . The probability of the first head on flip is , and the geometric series sums to 1. The event “first head on an even flip” has probability
These outcomes can be listed, so the space is countably infinite. They cannot all receive the same probability: a common positive weight would make the sum diverge, while a common zero weight would make it zero.
Key Takeaways
- An event is a set of outcomes; an outcome is one complete result.
- Outcome probabilities are nonnegative and sum to 1; add them to find an event probability.
- Use only for a finite space with equally likely outcomes.
- Multiply along a tree path and add across the event’s leaves.
- A countably infinite space cannot assign equal probability to every outcome.
1.2 Combine events without double counting
Use the complement for “at least one”
An event and its complement split the sample space, so . If the event is “at least one failure,” its complement is “no failures.” This can replace a long list of possible failure counts with one calculation.
For two independent fair die rolls, the probability of no six is . Therefore the probability of at least one six is . Adding gives too much because it includes the outcome with two sixes twice.
Subtract the overlap once
The addition rule is
The two single probabilities each include their shared outcomes. Subtracting one copy leaves each outcome in the union counted once. If the events are disjoint, the intersection is empty and the probabilities simply add.
Draw one card from a standard deck with 52 distinct cards, 13 in each suit and four of each rank. Let the event be “a heart or a king.” There are 13 hearts, four kings and one king of hearts. Thus
For “A but not B,” keep only the part of A outside the intersection:
For example, “a heart but not a king” has probability . This is a different question from “a heart or a king.”
Track three-way overlap
For three events, inclusion–exclusion gives
An outcome in all three events was added three times and subtracted three times. Adding its triple intersection restores one copy. The same alternating pattern continues for more events.
Choose an integer uniformly from 1 through 100. The counts divisible by 2, 3 and 5 are 50, 33 and 20. Their pairwise intersections contain 16, 10 and 6 numbers, and the triple intersection contains 3. The count divisible by at least one is , giving probability 0.74.
Bound a union when overlaps are unknown
The union bound drops all overlap corrections:
It holds for any events and needs no independence. If ten components each fail with probability at most 0.001, the chance of some failure is at most 0.01. This is an upper limit; it need not equal the true chance. If the sum exceeds 1, replace it by the trivial upper limit 1.
Set containment provides quick checks. If , then . In particular, an intersection cannot be more likely than either event, and a union cannot be less likely than either event. These checks catch errors such as reporting a probability of “both” that exceeds the probability of A alone.
Key Takeaways
- often makes “at least one” calculations shorter.
- The addition rule subtracts the intersection once.
- Three-event inclusion–exclusion adds back the triple intersection.
- The union bound is an upper limit that needs no independence.
1.3 Count the event and the sample space consistently
Choose an ordered or unordered model
In a uniform sample space, probability is a ratio of counts. The numerator and denominator must describe outcomes in the same way. For ordered draws from equally likely items, replacement gives sequences. Without replacement there are sequences. If order is ignored, sampling without replacement gives subsets.
For two draws from six distinct items, each unordered pair has two possible orders. Dividing both counts by the same factor leaves the probability unchanged. Counting an ordered event over an unordered sample space leaves that factor in only the numerator and gives a wrong probability.
Count a hand by its parts
A five-card hand is an unordered five-element subset of a standard 52-card deck. There are hands. To get exactly two aces, choose two of the four aces and three of the 48 non-aces:
The word “exactly” matters: choosing the other three cards from all 52 would allow extra aces and repeated cards. Choosing the two aces in ways would also count each selected pair twice.
A full house has three cards of one rank and two of another. Choose the triple’s rank in 13 ways and its suits in ways. Choose a different pair rank in 12 ways and its suits in ways. The count is
Dividing by the number of hands gives about 0.00144. The ranks play different roles, so choosing an unordered pair of ranks without assigning those roles would lose a factor of 2.
Count what does not happen
In four independent fair die rolls there are equally likely sequences. Exactly avoid a six. Therefore
This avoids separately counting one, two, three and four sixes.
Compare any birthday match with a match to one person
Model birthdays as independent and uniform across 365 days, leaving out February 29. For people, the first birthday is unrestricted, the next must avoid one day, the next must avoid two, and so on. Hence
Subtract this from 1 to find a shared birthday. The chance is about 0.507 for 23 people and 0.970 for 50. For more than 365 people, a match is certain in this model.
A different event is “someone shares my birthday.” Among 22 other people its probability is . A group of 23 contains 253 pairs, and any pair can provide a match; requiring a match with one specified person is much narrower.
Key Takeaways
- Both counts in a probability ratio must use the same ordering convention.
- Sampling without replacement uses distinct items and changing available choices.
- “Exactly” restricts both selected target items and the remaining items.
- Assign different roles when counting a triple rank and a pair rank.
- Count “none” and subtract from 1 for many “at least one” events.
- Any pair sharing a birthday differs from matching one specified person.
2Use new information to update probabilities
New information changes which outcomes remain relevant. Conditioning gives that change a precise meaning, and tree diagrams keep the order of events visible. You will test when information leaves a probability unchanged, distinguish pairwise from mutual independence, and use Bayes’ theorem to reason backward from evidence to a possible cause. Examples include sampling, reliability, diagnostic tests, and message filtering.
2.1 Condition on an event and split into cases
Restrict the space, then rescale
The conditional probability of A given B is
Keep the outcomes in B and measure what fraction of their probability lies in A. Conditioning on an event of probability zero leaves this ratio undefined. Within a fixed positive-probability condition, the usual rules still work; for example, .
Suppose two fair coin flips contain at least one head. Of the four equally likely ordered outcomes, only HH, HT and TH remain. The chance of two heads is therefore . If instead the first flip is known to be heads, only HH and HT remain, giving . Precise information determines the denominator.
Multiply along a path
Rearranging the definition gives the multiplication rule:
Draw two cards without replacement. The chance of an ace first is . After that ace, three aces remain among 51 cards, so
For a third event, multiply by its probability given both preceding events. A tree’s later branches carry these conditional probabilities. Using the original denominator at every branch would model replacement instead.
Add over a partition
A partition consists of disjoint cases that exhaust the sample space. If the cases all have positive probability, the law of total probability says
Machine 1 makes 60% of a factory’s chips with a 2% defect rate; machine 2 makes 40% with a 5% defect rate. A randomly selected chip is defective with probability . The rates are weighted by output shares, so taking their simple average would give the wrong answer.
Follow the information-producing process
In the Monty Hall problem, one of three doors hides a car. After your initial choice, a host who knows the location always opens another door hiding a goat and offers a switch. Switching wins exactly when your original choice was wrong. That happens with probability ; staying wins with probability . The host’s action is governed by a rule, so two unopened doors need not have equal winning chances.
Keep subgroup weights visible
Simpson’s paradox is a reversal between subgroup comparisons and the pooled comparison. Here is a numerical illustration using easy and hard jobs:
| Method | Easy jobs passed | Hard jobs passed | All jobs passed |
|---|---|---|---|
| A | 9/10 | 36/90 | 45/100 |
| B | 72/90 | 3/10 | 75/100 |
A has the higher pass rate in both groups: 90% versus 80%, and 40% versus 30%. B has the higher pooled rate because it receives many more easy jobs. Report a rate with its condition and compare how the cases are distributed.
Key Takeaways
- Conditioning keeps the given event and rescales its probability to 1.
- Use to multiply dependent stages.
- Total probability weights each case’s rate by its probability.
- The rule producing information matters in Monty Hall.
- Different subgroup weights can reverse a pooled comparison.
2.2 Test independence and distinguish it from disjointness
Use the product test
Events A and B are independent exactly when
For this is equivalent to : learning B gives no change in the chance of A. The product form also handles probability-zero events, which are independent of every event.
Independence can occur between events about the same experiment. On a fair die, let A mean “even” and B mean “at most 4.” Their probabilities are and ; their intersection is , with probability . The product is also , so the events are independent.
Do not confuse “no overlap” with “no change”
| Relationship | What it says | Consequence |
|---|---|---|
| Disjoint | The events have no shared outcomes. | If one occurs, the other cannot occur. |
| Independent | The intersection probability equals the product. | Learning one leaves the other’s chance unchanged. |
Two disjoint events of positive probability are dependent: their intersection probability is zero but the product is positive. For example, “roll a 1” and “roll a 6” cannot occur together. Independence would give a positive chance to both.
If A and B are independent, complementing either or both preserves independence. To see one case, subtract the intersection from A:
Check more than pairs for a collection
Pairwise independence checks every pair. Mutual independence checks the product rule for every subcollection, including triples and larger groups.
Flip two independent fair coins. Let A be “first is heads,” B be “second is heads,” and C be “the coins match.” Each event has probability . Every pair occurs together with probability , so the events are pairwise independent. But all three occur only for HH:
The three events are not mutually independent. Knowing both coin results determines whether they match, even though either result alone leaves the matching chance unchanged.
Apply independence to repeated trials
Three servers are each up with probability 0.9, mutually independently. The chance all are down is , so the chance at least one is up is . A shared power supply can make simultaneous failures more common than that product predicts. Dependence alone does not determine the direction of the difference; the joint probability must be compared with the product.
The gambler’s fallacy treats independent trials as if they compensate for past results. After five heads from a fair coin, the next head still has probability . The specific sequence of six heads was unlikely before flipping began, but once the first five results are known, only the last flip remains uncertain.
Key Takeaways
- Independence means .
- Disjoint positive-probability events are dependent.
- Complementing independent events preserves independence.
- Pairwise independence checks pairs; mutual independence checks every subcollection.
- Independent trials do not compensate for past outcomes.
2.3 Reverse a conditional probability with Bayes’ theorem
Follow the joint probability in both directions
A test’s sensitivity answers “How often is a person with the condition positive?” It does not answer “How often does a positive person have the condition?” These questions condition on different groups. Bayes’ theorem connects them:
Both numerator forms equal before division by . Here is the prior, the likelihood, and the posterior. The denominator gathers all ways to observe B.
Count true and false positives
A condition affects 1% of a population. A diagnostic test has 99% sensitivity and a 5% false-positive rate. In a group of 10,000 people, the model gives 100 with the condition and 9,900 without it. The positive groups are 99 true positives and 495 false positives. Thus
The formula calculation is identical:
The specificity is the chance of a negative result among people without the condition: 95% here. Subtract specificity from 1 to obtain the false-positive rate. Substituting 95% where the denominator needs 5% reverses that branch.
Base-rate neglect drops the small prior and treats sensitivity as the posterior. The large group without the condition can supply most positive results even when its positive rate is small. Reversing “evidence given innocence” into “innocence given evidence” makes the same error in legal reasoning, often called the prosecutor’s fallacy.
Update again with fresh evidence
A posterior can become the next prior. If a second test is conditionally independent of the first given disease status, the same likelihoods apply within each status group. Two positive results give
Conditional independence is essential here: a repeated test that copies the first result supplies no fresh information.
Allow several possible causes
For a partition of positive-probability causes,
If 60% of chips come from a machine with a 2% defect rate and 40% from one with a 5% rate, the total defect probability is 0.032. A defective chip came from the second machine with probability .
Message filtering works the same way. If “offer” appears in 25% of spam and 2% of legitimate messages, equal priors give spam probability after observing that word. A spam prior of 0.8 raises it to about 0.980. Naive Bayes combines several word clues by modeling them as conditionally independent given the message class.
Key Takeaways
- Bayes’ theorem reverses conditioning by using the prior and the likelihood.
- The denominator includes evidence from every possible cause.
- Sensitivity and the posterior after a positive test answer different questions.
- Specificity is one minus the false-positive rate.
- Repeated evidence needs its correct conditional likelihoods.
3Turn outcomes into numerical distributions
An outcome may contain much more detail than a question needs. A random variable extracts a number, such as a count of lost packets or the number of trials before a success. You will collect probabilities for those values, read cumulative probabilities, and examine two variables together. Choosing a standard distribution then becomes a question about the process: what is fixed, what changes, and which trials are independent?
3.1 Build a PMF, a CDF, and a joint distribution
A random variable assigns a number
A random variable is a function . Its rule is fixed; the random outcome determines which value is observed. In three fair coin flips, let X count heads. Both HHT and HTH map to 2, although they are different outcomes.
Each value defines an event: contains all outcomes mapped to x. The probability mass function, or PMF, is . Collect the outcome weights for each value, then check that the masses are nonnegative and sum to 1.
For three independent fair flips:
| Heads, x | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| P(X = x) | 1/8 | 3/8 | 3/8 | 1/8 |
The values are not equally likely: three sequences give one head but only one gives no heads. A random variable can collect equal-weight outcomes into unequal-weight groups.
Add masses to get cumulative probabilities
The cumulative distribution function, or CDF, is . It is nondecreasing, approaches 0 and 1 at the two extremes, and includes the mass at its argument. In the table, . For it remains ; at 2 it jumps to . The jump at a possible value equals its PMF mass.
To extract an interval probability, subtract cumulative totals:
Subtracting the total through a removes a itself. For example, . Endpoint symbols tell you which masses to retain.
Use indicators for yes/no events
The indicator of A, written , equals 1 when A occurs and 0 otherwise. A count of successful checks can be written as a sum containing an indicator for each check. This makes each event’s contribution explicit even when the whole count has a complicated distribution.
Keep two variables together
A joint distribution lists for every pair. Sum a row or column to get a marginal distribution: . X and Y are independent if every joint entry equals the product of its two marginal probabilities.
For two independent fair dice, the individual results are independent. The first die and their sum are dependent: a first die of 1 cannot occur with a sum of 12, although both single events have positive probability. A failed product equality establishes dependence; independence requires all pairs to pass.
Transform values by collecting outcomes
Let M be the maximum of two independent fair dice. There are pairs with both values at most k, and with both at most k minus 1. Subtract to find
At k = 6 this gives . Applying a function to outcomes creates another random variable, but it does not make its distinct values equally likely.
Key Takeaways
- A random variable maps outcomes to numbers.
- A PMF collects the probability of each value and must sum to 1.
- A CDF includes all mass at or below its argument.
- Joint distributions yield marginals by summation.
- Independence of variables requires the product rule for every value pair.
- To find a transformed distribution, group outcomes that give the same value.
3.2 Choose a distribution from the experiment
Match the question to the process
| Model | What is measured | Required structure |
|---|---|---|
| Uniform | One of n equally likely values | A finite set with equal masses |
| Bernoulli | A single success indicator | Values 1 and 0 with success chance p |
| Binomial | Successes in n trials | Fixed n, independent trials, same p |
| Geometric | Trials through the first success | Independent trials, same positive p |
| Hypergeometric | Successes in a sample | Uniform sampling without replacement |
Uniform on gives probability to each value. A Bernoulli variable has and . The label “success” names the counted result; it need not describe a desirable outcome.
Count successes in a fixed number of trials
For ,
A particular sequence with k successes has probability . The coefficient counts which trial positions contain them. Leaving it out gives only one sequence’s probability. The binomial theorem verifies that all masses sum to 1.
Ten packets are lost independently with probability 0.3 each. Exactly three losses have probability
“At most one” adds the masses for zero and one: . A fixed trial count does not by itself justify a binomial model; equal success probabilities and independence are also needed.
Wait until a first success
For a geometric variable X counting trials through the first success,
The first expression requires k minus 1 failures followed by a success. The second requires k failures and says nothing about trial k plus 1. For the first six on a fair die, and .
Some books count failures before success instead. That variable is X minus 1, starts at zero, and has mean one less. Identify the counting convention before choosing an exponent.
The geometric distribution is memoryless:
After m failures, the chance of another n failures remains . Geometric distributions are the memoryless distributions on positive integers.
Handle sampling without replacement
A batch contains four defective and 16 working items. Draw five uniformly without replacement. Each selection changes what remains, so a binomial count is inappropriate. The hypergeometric formula is
The numerator chooses k defective items and the remaining five minus k from the working items. Values of k must be feasible for both groups. This is the same consistent unordered counting used for card hands.
Key Takeaways
- Binomial counts successes in a fixed number of independent trials with the same success probability.
- The binomial coefficient counts all successful position patterns.
- Geometric counts trials through the first success and starts at 1.
- Sampling without replacement leads to a hypergeometric count.
4Find average outcomes without listing every case
Expected value turns a distribution into a probability-weighted average. It can describe a game’s net gain, a waiting time, or the number of events that occur, even when that average is not a possible result of one run. You will calculate expectations directly and by conditioning, then use linearity and indicators to avoid difficult distributions. Dependence matters for products, but it does not prevent adding finite expectations.
4.1 Calculate means, transformed values, and conditional means
Weight each value by its probability
The expected value, or mean, of X is
Equivalently, sum over outcomes s. Values with greater probability contribute more weight. A fair die has mean , even though no face shows that value. Expectation describes the long-run average of repeated independent runs with a finite mean; it is not a prediction that the next result will equal the mean.
A game costs two tokens and pays ten tokens when a fair die shows six. The net gain is eight on a win and minus two otherwise:
The expected loss is one-third of a token per game. Averaging the payout alone gives , but that leaves out the fee. Subtracting the fee once from expected payout gives the same net result.
Average the function you actually need
For a function g,
You can use the original distribution without first constructing the distribution of g(X). Squaring values before averaging differs from squaring their average. On a fair die,
Nonlinear operations such as squaring or taking reciprocals generally cannot be moved through expectation.
For a nonnegative integer-valued X, the tail-sum formula is
A value x contributes one unit to each of the first x tails, so those contributions add to x. For a fair die the sum is .
Condition on a useful first case
For an event A of positive probability,
If positive-probability events form a partition, the law of total expectation weights their conditional means:
For geometric waiting with success chance p, let the finite mean be m. A first-trial success uses one trial. After a failure, one trial is used and an independent copy of the same waiting process remains. Thus
This agrees with the tail sum , which also establishes finiteness for positive p.
Check convergence for infinite ranges
A finite expectation requires . Infinite support alone does not cause trouble: geometric waiting has a finite mean. But in the St. Petersburg game, a first head on flip k pays tokens with probability . Every k contributes one token to the expectation series, so the total diverges to positive infinity. The game has no finite mean payout.
Key Takeaways
- Expectation is a probability-weighted average and need not be an attainable value.
- Use net gain when a game charges a fee.
- Apply a function to each value before averaging it.
- Total expectation weights conditional means by case probabilities.
- An infinite-range variable needs a convergence check for a finite mean.
4.2 Use indicators and linearity for expected counts
Add expectations even with dependence
For variables with finite expectations and constants a and b,
Linearity of expectation needs no independence. In the outcome-by-outcome sum, distributing addition separates the contributions from X and Y. The same argument works for any finite sum.
A count often becomes easy after defining one indicator per possible event. If is 1 when event occurs and 0 otherwise, then . Therefore
You need each event’s probability, not the distribution of the total count. A binomial count has n indicators of mean p, giving .
Count correct returns in a random permutation
Suppose n hats are returned uniformly at random. Let indicate that person i gets their own hat. Each person’s hat is equally likely to be any of the n hats, so . The expected number of correct returns is
The indicators are dependent: if all but one hats return correctly, the last one must also be correct. That dependence does not affect this calculation. An expected count of one also does not mean that exactly one match occurs in every return.
Count pairs, not people
Among 23 people with independent uniform birthdays on 365 days, define an indicator for each pair sharing a birthday. There are pairs, each matching with probability . The expected number of matching pairs is .
This is not the probability of a birthday match. A group can contribute more than one matching pair. Expected counts can exceed 1, while event probabilities cannot.
Break a long wait into phases
In the coupon collector problem, each draw independently gives one of n equally likely types. After i distinct types have appeared, the chance of a new type is . The waiting time for the next new type is geometric with mean .
The full collection time is the sum of these phase lengths:
For six die faces this is rolls. The final missing type alone takes six rolls on average, explaining why completion takes longer than six rolls. Linearity adds the phase means without requiring a separate independence proof for the phases.
Treat products separately
For independent variables with finite expectations, . This can fail with dependence. Let X and Y both be the indicator of heads on the same fair flip. Their product equals that same indicator, so , whereas .
Key Takeaways
- Finite expectations add regardless of dependence.
- An indicator’s expectation equals the probability of its event.
- Choose indicators for exactly what is being counted, such as pairs.
- Coupon collection has mean n times the nth harmonic number.
- Expected counts and probabilities are different quantities.
- Factoring the expectation of a product needs additional conditions, such as independence.
5Measure spread and bound rare outcomes
Two random variables can have the same mean and behave very differently on individual runs. Variance measures squared distance from the mean, while standard deviation expresses spread in the original units. You will track how shifts, scaling, and dependence affect spread, then use Markov, Chebyshev, and Chernoff bounds to limit rare outcomes. These bounds trade detailed distribution information for guarantees under clear conditions.
5.1 Calculate variance and keep dependence in the formula
Square distances before averaging
If , the variance is
Positive and negative deviations cancel when averaged directly. Squaring makes both contribute positively. The standard deviation is . If X is measured in milliseconds, variance has units of square milliseconds and standard deviation has units of milliseconds.
A sure payout of 50 tokens and an equally likely payout of zero or 100 tokens both have mean 50. The sure payout has variance zero. The random payout is always 50 tokens from its mean, so its variance is . A mean alone hides this difference.
Expanding the square gives a convenient computational formula:
For a fair die, and . Thus , and . Keep the two second-moment quantities separate: the average of squares is not the square of the average.
Shift and scale the distribution
For constants a and b,
A shift moves the values and their mean by the same amount, preserving all deviations. Scaling multiplies each deviation by a and each squared deviation by its square. Standard deviation therefore scales by . Even a negative scale leaves variance nonnegative.
Add the covariance term for sums
Covariance measures joint variation:
Expanding a sum’s squared deviation gives
Independent variables have covariance zero. For a finite sum of pairwise independent variables, all covariance terms vanish, so the variances add. For independent X and Y, the variance of their difference also adds: the coefficient of Y is squared. Standard deviations themselves generally do not add.
Two copies of the same variable need different treatment. The expression X plus X is exactly twice X, with variance . Two independent copies have sum variance . They may have the same individual distribution while having a different joint relationship.
Use standard results
| Distribution | Mean | Variance |
|---|---|---|
| Bernoulli(p) | p | p(1 − p) |
| Binomial(n, p) | np | np(1 − p) |
| Geometric(p), trials through success | 1/p | (1 − p)/p² |
A binomial variable is a sum of independent Bernoulli indicators, which explains its mean and variance. For 100 independent fair flips, the head count has mean 50, variance 25, and standard deviation 5. For rolls until the first six, the mean is 6 and the variance is 30.
Key Takeaways
- Variance averages squared distances; standard deviation returns to the original units.
- Compute variance as .
- Shifts preserve variance; scaling by a multiplies variance by its square.
- A sum’s variance includes covariance terms.
- Pairwise independence is enough for variances to add.
- Repeated use of the same variable differs from independent copies.
5.2 Choose a bound and check its conditions
Markov: use a nonnegative variable and its mean
For and , Markov’s inequality states
Values at least a contribute at least a times their probability to the mean. This gives the bound without a full distribution. A nonnegative response time averaging 20 ms has probability at most of reaching 100 ms. A result above 1 gives no useful improvement over the probability limit 1. Applying this inequality directly to a variable that can be negative is invalid.
Chebyshev: use squared distance and variance
Apply Markov to the nonnegative variable . For any and finite variance,
When , setting gives the bound . If variance is zero, X equals its mean with probability 1. Chebyshev’s inequality controls both tails together and needs no independence for a single variable.
For 100 independent fair flips, the head count has mean 50 and variance 25. Hence . The exact probability is about 0.057. A guaranteed upper bound can be much larger than the actual probability; it is not an estimate or an equality.
Control an average
For n pairwise independent variables with common mean and finite variance , their average has variance . Chebyshev gives
The right side tends to zero for every fixed positive tolerance. This proves the weak law of large numbers under these conditions. For fair-flip indicators, requiring error less than 0.05 with probability at least 0.95 is guaranteed by , giving . This is a sufficient size, not the smallest possible size.
Chernoff: exploit independent bounded summands
Let , where the summands are mutually independent and each lies in . With and ,
For 1,000 independent fair flips, . The threshold 600 corresponds to , so the bound is . Chebyshev gives 0.025 for this event by bounding the larger two-sided event. The exact upper-tail probability is about .
Chernoff’s exponential form can be far sharper, but its summand conditions must hold. Pairwise independence alone supports the variance calculation for Chebyshev; the stated Chernoff form requires mutual independence.
Key Takeaways
- Markov needs a nonnegative variable and a positive threshold.
- Chebyshev bounds both tails using a finite variance.
- For pairwise independent equal-variance observations, the average’s variance decreases as 1/n.
- The stated Chernoff bound requires mutually independent summands in [0, 1].
- Report a bound as an upper limit; a sufficient sample size need not be minimal.
6Analyze random choices in algorithms
Random choices can make an algorithm fast on average or make an inexpensive check reliable after repetition. The input can remain fixed while those choices vary. You will distinguish random running time from possible output error, reduce one-sided error, and analyze expected comparisons and hash collisions. Indicator arguments also lead to existence proofs: a favorable average can guarantee that at least one useful object exists.
6.1 Separate random running time from random error
Fix the input and vary the random choices
A randomized algorithm uses random choices during its execution. For one fixed input, those choices can change the runtime, the output, or both. An expected runtime averages over the algorithm’s choices on that input. A worst-case expected runtime takes the largest such expectation among inputs of the same size.
| Type | Correctness | Running time |
|---|---|---|
| Las Vegas | Always correct | Random |
| Monte Carlo | May be wrong, with a bounded error chance | Has a fixed time bound |
Randomized quicksort is Las Vegas. A matrix-product check with a fixed number of random trials is Monte Carlo.
Repeat a one-sided test
Suppose true “yes” inputs always pass, while each fixed “no” input passes with probability at most . Run k independent trials and accept only if all pass. A “no” input is wrongly accepted only if every trial misses it, so its error probability is at most . True “yes” inputs still always pass.
Independence refers to fresh random choices in the trials. Reusing one random vector repeatedly does not multiply the guarantee. The bound concerns a fixed false input’s chance of passing; it is not the posterior probability that an accepted input is false.
Check primality or a matrix product
A prime always passes Miller–Rabin. For an odd composite n, at most one-quarter of the bases from 1 through n minus 1 let it pass. Uniform independent bases give error at most on each such composite. Ten trials give about . A “composite” verdict is conclusive.
Freivalds’ check tests for square matrices by choosing a vector r of independent fair bits and comparing with . Matrix-vector products use arithmetic operations. Equality always passes; a false product passes with probability at most .
For
the last entry should be 50. Vector misses the error, while exposes it: the second components are 50 and 51. Two of the four bit vectors miss it. Twenty independent trials give miss probability .
Turn expectations into tail guarantees
If runtime R is nonnegative and on an input, Markov gives . A small expected time allows occasional slow runs. It does not assert a fixed time limit for every run.
With high probability means that failure tends to zero as input size n grows, often at a rate for a positive constant c. If each of n steps fails with probability at most , the union bound gives total failure at most . The steps need not be independent for this bound.
Key Takeaways
- Randomized analysis can fix the input and average over internal choices.
- Las Vegas guarantees correctness; Monte Carlo allows bounded output error.
- Independent repetition reduces the stated one-sided error to its kth power.
- Freivalds’ check uses matrix-vector products and has one-sided error.
- Markov controls runtime tails; a union bound controls any step failing.
6.2 Count comparisons, collisions, and favorable objects
Define one indicator per quicksort pair
Randomized quicksort selects each pivot uniformly from the current part. For distinct sorted values , a pair is compared exactly when the first pivot from is either endpoint. An interior pivot separates the pair permanently. Each of the values is equally likely to be first, so
Let an indicator record each pair’s comparison. Linearity gives the expected total
Here lies between and . Thus expected comparisons grow like , giving . A worst-case run compares every pair, using comparisons.
For three values, a middle first pivot uses two comparisons; an endpoint first pivot needs three. The mean is . For 1,000 values the formula gives about 10,986 comparisons, compared with 499,500 in the worst case.
Define indicators for colliding key pairs
Under simple uniform hashing, k keys choose independently and uniformly among m slots. Each pair collides with probability . Therefore
The expected number of keys in a specified slot is the load factor . These are different counts: a slot holding three keys contributes three colliding pairs.
For 100 keys and 1,000 slots, the expected colliding-pair count is 4.95. The no-collision probability is
This is the birthday calculation with slots replacing days. A collision chance near one-half occurs at about keys for large m; for 32-bit values it is about 77,000 values. The approximation concerns any matching pair, not a match to one fixed key.
Turn a mean into an existence proof
The probabilistic method builds an object at random and proves a desired outcome has positive probability. If a finite random variable has mean at least t, some outcome has value at least t.
Place each vertex of a graph independently on either side of a cut with equal probability. Each edge crosses with probability . If there are m edges, the expected crossing count is , so some cut has at least that many edges.
The Ramsey number is the smallest vertex count for which every red–blue coloring of a complete graph’s edges contains a monochromatic k-vertex complete subgraph. To find a lower bound, color each edge of a complete graph on N vertices independently red or blue. A particular k-vertex set is monochromatic with probability . The expected number of such sets is
If this is below 1, some coloring has zero such sets: a nonnegative integer count that were always positive would have mean at least 1. Thus . Choosing yields the lower bound for . To check the expectation bound, use . This gives an upper limit . It is below 1 at k = 3 and decreases thereafter: increasing k by 1 multiplies it by . If the displayed N is below k, there are no k-vertex sets at all. Finally, the integer inequality R greater than N also gives R greater than . The argument guarantees a coloring without finding it.
Key Takeaways
- Quicksort compares a pair when an endpoint is its interval’s first pivot.
- Sum comparison probabilities to get expected quicksort comparisons.
- Hash collision pairs have expectation equal to the number of pairs divided by slots.
- A favorable average guarantees at least one favorable outcome.
- An integer-valued bad-object count with mean below 1 can be zero.
- Existence arguments need not construct the promised object.
Discrete Probability examples
1Build and check a probability calculation
15 steps
- 1IntroductionDescribe one complete result
A probability model has to describe a complete result before it can assign a chance. We will distinguish outcomes from events, use event rules to handle overlap, and then count samples without replacement. Watch how the same choice—whether a result records order—affects both the event and the sample space.
- 2ExplanationChoose the detail in an outcome
Roll two independent fair dice and record the first result followed by the second. Each outcome is an ordered pair. There are 36 pairs, and each has probability . The event “sum 7” groups six pairs, while “sum 2” groups only one. Recording just the sum is possible, but those sum outcomes need unequal weights.
- 3ExampleAssign and add weights
A sensor reports green, amber, or red with probabilities 0.6, 0.3, and 0.1. These are nonnegative and total 1, so they form a probability assignment. The event “not green” collects amber and red, with probability 0.4. The event is a set of complete results; its probability comes from adding their weights.
- 4ChallengeCheck a proposed uniform space
A learner lists the sums 2 through 12 of two independent fair dice and assigns each probability . Is that the correct distribution?
---reveal---
No. The sums occur through different numbers of ordered pairs. For example, sum 2 occurs only through , while sum 7 has six pairs. The weights total 1, but they model a different experiment.
- 5ConnectionLet a wait have infinitely many values
Flip a fair coin until the first head. Stopping on flip k requires k minus 1 tails and then a head, with probability . The probabilities sum to 1. An infinite list can therefore have valid unequal weights. Equal positive weights would diverge, and equal zero weights would have total zero.
- 6ExampleUse “none” to find “at least one”
Two independent sensors each miss a signal with probability 0.2. The probability neither misses it is . The event “at least one misses” is its complement, so its probability is . This collects one miss and two misses in a single calculation without listing the possible patterns separately.
- 7Key InsightCorrect an overlap
The sum counts a double miss twice. The intersection has probability , so subtracting one copy gives . This is the addition rule: add the two event probabilities and subtract their intersection. Independence helped find this intersection; the addition rule itself needs no independence.
- 8ChallengeUse a guarantee with missing overlap data
Four checks each fail with probability at most 0.03. Their dependence is unknown. What upper limit can you guarantee for at least one failure?
---reveal---
The union bound gives at most . It works without independence or intersection data. The sum is an upper limit; the actual union can be smaller if some failures share outcomes.
- 9ExplanationRestore a three-way overlap
With three events, inclusion–exclusion adds the single probabilities, subtracts the three pairwise intersections, and adds the triple intersection. Trace one outcome present in all three: it is added three times, then subtracted three times. Without the final addition it would disappear, even though it belongs in the union.
- 10ExplanationCount unordered samples
A bag has five green and three purple distinct tiles. Draw three uniformly without replacement and ignore order. The sample space consists of equally likely three-tile subsets. To get exactly two green tiles, choose two of the five green tiles and one of the three purple tiles. Both counts describe subsets.
- 11ExampleComplete the numerator
There are favorable subsets. The probability is . The purple choice enforces “exactly two green”: choosing the third tile from the entire bag would allow three green tiles and could repeat a tile already chosen. Each factor has a distinct role in the selection.
- 12ChallengeCheck an ordered numerator
For the same bag, someone uses as the numerator and 56 as the denominator. Why does this fail?
---reveal---
The two green tiles are ordered in the numerator but not in the denominator. Each favorable subset is counted twice. Divide by to recover 30, or rebuild both counts using fully ordered draw sequences.
- 13TipDistinguish two matching questions
For n independent uniform birthdays, the chance of no match is the product of the unused-day fractions. Its complement counts a match in any pair. Asking whether someone matches one specified person instead uses a fixed target day. Write the event in words before choosing a count: a fixed-person match and any-pair match collect different outcomes.
- 14ChallengeCombine counting with a complement
In the eight-tile bag, what is the probability of at least one purple tile in three draws without replacement?
---reveal---
The complement is three green tiles, with subsets out of 56. The answer is . Adding the probabilities of purple on individual draws would require correcting their overlaps.
- 15RecapCheck the model before the arithmetic
For a new problem, first decide what a complete outcome records. Give its weight, describe the event, and check whether counting or a weighted sum fits. Overlap corrections and complements organize the event calculation; consistent ordered or unordered counts organize sampling. A result outside [0, 1] signals that the model or arithmetic needs another look.
2Follow information from causes to evidence and back
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionKeep the direction of a question visible
- 2ExplanationRestrict to the known group
- 3ExampleMultiply a branch and its condition
- 4ExampleAdd the alternate route
- 5ChallengeFind the right conditional denominator
- 6Key InsightAsk how evidence was selected
- 7ExplanationCalculate before claiming independence
- 8ChallengeKeep disjointness separate
- 9ConnectionTest the whole collection
- 10ExplanationReverse the route question
- 11ExampleCalculate the posterior
- 12ChallengeChange the direction of inference
- 13AnalogyMake base rates concrete
- 14TipCheck whether repeated evidence is fresh
- 15ChallengeConnect the denominator to the model
- 16RecapSeparate restriction, combination, and reversal
3Build a distribution and choose a model
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionExtract the number a question needs
- 2ExampleMap pairs to a maximum
- 3ExampleFind each mass by subtraction
- 4ExplanationAccumulate the masses
- 5ChallengeRead an interval with endpoints
- 6Key InsightTest a joint relationship
- 7ExplanationRecord one trial or count many
- 8ExampleInclude all success positions
- 9ChallengeDecide what stopping changes
- 10ExampleKeep a mass separate from a tail
- 11ConnectionRestart the remaining wait
- 12TipRecognize removal from a population
- 13ChallengeBuild a different sample model
- 14RecapLet the process select the formula
4Calculate averages by cases and indicators
13 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionChoose the quantity to average
- 2ExampleInclude the fee in every outcome
- 3ExampleForm the weighted average
- 4ChallengeTransform before you average
- 5ExplanationCondition on the first trial
- 6Key InsightRecognize an infinite average
- 7ExplanationCount with one indicator per event
- 8ChallengeKeep dependence out of an additive calculation
- 9TipChoose the counted object carefully
- 10ExampleSplit a collection into phases
- 11ExampleAdd the collection waits
- 12ChallengeCombine collection and a cost
- 13RecapUse the easiest representation of the mean
5Turn spread into a probability guarantee
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionAsk what the mean leaves unknown
- 2ExampleCompare two equal-mean variables
- 3ExampleUse the second moment
- 4Key InsightDistinguish a scale from new randomness
- 5ChallengeHandle a difference of independent times
- 6ExplanationUse a nonnegative time and its mean
- 7ExampleUse variance for deviation from a mean
- 8ChallengeSelect a bound from the information
- 9ExplanationAverage repeated measurements
- 10ChallengeChoose a sufficient number of observations
- 11ExplanationExploit bounded independent trials
- 12ExampleMatch the threshold to a multiplier
- 13ChallengeChoose between available guarantees
- 14RecapMatch the guarantee to its conditions
6Use random checks and count algorithm events
17 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionFix the input before taking a probability
- 2ExplanationSeparate error from runtime
- 3ExplanationCheck a product through a random vector
- 4ExampleSee how an error can be missed
- 5ExampleMultiply independent miss probabilities
- 6ChallengeDecide how many fresh trials are needed
- 7ConnectionTurn mean time into a tail bound
- 8ExplanationFind the quicksort event for one pair
- 9ExampleCount favorable first pivots
- 10ChallengeCheck an adjacent pair
- 11Key InsightSeparate expected work from a worst run
- 12ExampleCount hashing pairs
- 13ChallengeCount several keys in one slot
- 14ConnectionUse a mean to guarantee a cut
- 15ChallengeUse an integer count below one
- 16TipCombine small failure risks
- 17RecapState exactly what the guarantee covers
Discrete Probability practice questions
Set 1: Build models and interpret probabilities10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Choose models and combine useful rules10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Combine distributions and conditional reasoning10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Reason with bounds and dependent counts10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Solve unfamiliar probability problems10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
B
Base-rate neglect
Bayes’ theorem
Bernoulli distribution
Binomial distribution
Birthday problem
C
Chebyshev’s inequality
Chernoff bound
Colliding pair
Complement
Conditional expectation
Conditional probability
Countably infinite sample space
Coupon collector problem
Covariance
Cumulative distribution function
D
Disjoint events
E
Error amplification
Event
Expected value
Experiment
G
Gambler’s fallacy
Geometric distribution
H
Harmonic number
Hypergeometric distribution
I
Inclusion–exclusion
Independence of events
Independent random variables
Indicator variable
Intersection
J
Joint distribution
L
Las Vegas algorithm
Law of total expectation
Law of total probability
Likelihood
Linearity of expectation
Load factor
M
Marginal distribution
Markov’s inequality
Memorylessness
Monotonicity
Monte Carlo algorithm
Multiplication rule
Mutual independence
N
Net gain
O
One-sided error
Outcome
P
Pairwise independence
Partition
Posterior probability
Prior probability
Probabilistic method
Probability function
Probability mass function
R
Ramsey number
Random variable
Randomized algorithm
S
Sample space
Sampling with replacement
Sampling without replacement
Second moment
Sensitivity
Simple uniform hashing
Simpson’s paradox
Specificity
Standard deviation
T
Tail-sum formula
U
Uniform distribution
Uniform sample space
Union
Union bound
Upper bound
V
Variance
W
Weak law of large numbers
With high probability
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.