Discrete Random Variables
This session introduces random variables as numerical functions of outcomes and models their countable values using PMFs and CDFs. Expectation and variance are introduced as properties of a probability model rather than summaries calculated from an observed data sample. The central models are Bernoulli, geometric, binomial, negative binomial (Pascal), hypergeometric, and Poisson distributions.
A probability mass function assigns probability to each possible value; the CDF accumulates those probabilities. Expectation and variance follow from the PMF. Choosing a named distribution is a modelling step: a single trial, a fixed number of independent trials, waiting for the first success, waiting for a fixed number of successes, sampling without replacement, and counting events each point to a different family. The Poisson distribution is also used as an approximation to the binomial distribution under suitable conditions.
Key Concepts¶
- Random variables as numerical functions of outcomes
- Probability mass functions and CDFs
- Expectation and variance of a discrete random variable
- Bernoulli, geometric, binomial, negative binomial (Pascal), hypergeometric, and Poisson models
- Poisson approximation to the binomial distribution
- Matching a distribution to the assumptions of a problem
Learning Objectives
- Define a discrete random variable and identify its possible values.
- Validate and use a PMF and construct its CDF.
- Calculate and interpret expectation and variance as model properties.
- Distinguish a single Bernoulli trial, a fixed number of trials, waiting for one or more successes, sampling without replacement, and count models.
- Use a Poisson distribution as an approximation to a binomial distribution when appropriate.
Session Preparation:¶
Attempt the exercises from Session 1.
Syllabus and input
- Probability mass functions
- Special discrete distributions
- Cumulative distribution functions
- Expectation
- Variance and standard deviation
Existing course material
Exercises¶
Exercise 1 — Password hits¶
A computer system uses passwords that are exactly six characters, and each character is one of the 26 letters (a-z) or 10 integers (0-9). Suppose that 10,000 users of the system have unique passwords. A hacker randomly selects, with replacement, 100,000 passwords from the potential set. A match to a user's password is called a hit.
- What is the distribution of the number of hits?
- What is the probability of no hits?
- What are the mean and variance of the number of hits?
Answer
- \(X\sim\operatorname{Binomial}(100{,}000,10{,}000/36^6)\).
- \(P(X=0)\approx0.6317\).
- \(E[X]\approx0.4594\) and \(\operatorname{Var}(X)\approx0.4594\).
Exercise 2 — Airline overbooking¶
An airline sells 125 tickets for a flight with 120 seats. Each passenger independently fails to appear with probability 0.10.
- Find the probability that everyone who appears can take the flight.
- Find the probability that the flight leaves with at least one empty seat.
Answer
- \(P(X\le120)\approx0.9961\), where \(X\sim\operatorname{Binomial}(125,0.9)\) is the number of passengers who appear.
- \(P(X\le119)\approx0.9886\).
Exercise 3 — Video-game opponents¶
A player defeats each opponent independently with probability 0.8 and continues until the first defeat. Let \(X\) be the number of opponents contested.
- What is the probability mass function of the number of opponents contested in a game?
- What is the probability that a player defeats at least two opponents in a game?
- What is the expected number of opponents contested in a game?
- What is the probability that a player contests four or more opponents in a game?
- What is the expected number of game plays until a player contests four or more opponents?
Answer
- \(P(X=k)=0.8^{k-1}\cdot0.2\), for \(k=1,2,\ldots\).
- \(0.8^2=0.64\).
- \(E[X]=5\).
- \(0.8^3=0.512\).
- \(1/0.512\approx1.9531\).
Exercise 4 — Stars in space¶
The local density of stars is one star per 16 cubic light-years. Model counts in disjoint volumes as independent.
- Find the probability of no stars in 16 cubic light-years.
- Find the probability of at least two stars in that volume.
- Find the volume needed for the probability of at least one star to exceed 0.95.
Answer
- \(P(X=0)=e^{-1}\approx0.3679\).
- \(P(X\ge2)=1-2e^{-1}\approx0.2642\).
- At least 48 cubic light-years must be studied.
Exercise 5 — Lost data packets¶
A packet is lost independently with probability 0.01, and a message contains 100 packets.
- What is the distribution of the number of packets in an e-mail message that must be resent? Include the parameter values.
- What is the probability that at least one packet is resent?
- What is the probability that two or more packets are resent?
- What are the mean and standard deviation of the number of packets that are resent?
- Simulate 10,000 e-mail messages and compare the simulated probabilities of at least one and at least two lost packets with the exact probabilities.
Answer
- \(X\sim\operatorname{Binomial}(100,0.01)\).
- \(P(X\ge1)\approx0.6340\).
- \(P(X\ge2)\approx0.2642\).
- \(E[X]=1\) and \(\operatorname{SD}(X)=\sqrt{0.99}\approx0.995\).
- The simulated probabilities should approach \(0.6340\) and \(0.2642\), respectively.
Exercise 6 — Warranty failures¶
A manufacturer expects 2% of its units to fail during the warranty period. A sample of 500 independent units is followed.
- What is the probability that none fail during the warranty period?
- What is the expected number of failures during the warranty period?
- What is the probability that more than two units fail during the warranty period?
- Approximate the probabilities in parts 1 and 3 with a Poisson distribution, and compare the results with the exact binomial probabilities.
Answer
- \(P(X=0)\approx0.0000\), where \(X\sim\operatorname{Binomial}(500,0.02)\).
- \(E[X]=10\).
- \(P(X>2)\approx0.9974\).
- Using \(Y\sim\operatorname{Poisson}(10)\), \(P(Y=0)\approx0.0000454\) and \(P(Y>2)\approx0.9972\). The corresponding exact binomial values are approximately \(0.0000410\) and \(0.9974\), so the approximation is close.
Exercise 7 — Recovery from a rare disease¶
The probability that a patient recovers from a rare blood disease is 0.4. Fifteen people are known to have contracted the disease.
- What is the probability that at least 10 survive?
- What is the probability that from 3 to 8 survive?
- What is the probability that exactly 5 survive?
- Find the mean and variance of the number who survive.
Answer
- \(P(X\ge10)\approx0.0338\).
- \(P(3\le X\le8)\approx0.8778\).
- \(P(X=5)\approx0.1859\).
- \(E[X]=6\) and \(\operatorname{Var}(X)=3.6\).
Exercise 8 — Shipments containing defects¶
Each device is defective independently with probability 0.03. An inspector examines 20 devices from each of 10 shipments.
- Find the probability that a particular inspected shipment contains at least one defective device.
- State the distribution of the number of inspected shipments containing at least one defective device.
- Find the probability that exactly three shipments contain at least one defective device.
Answer
- For one shipment, \(P(X\ge1)=1-0.97^{20}\approx0.4562\).
- Let \(q=1-0.97^{20}\). Then \(Y\sim\operatorname{Binomial}(10,q)\), and \(P(Y=3)={10\choose3}q^3(1-q)^7\approx0.1602\).
Exercise 9 — Negative binomial model¶
Each inspected unit is acceptable independently with probability 0.8. Let \(X\) be the number of units inspected up to and including the fourth acceptable unit.
- Identify the distribution of \(X\) and state its possible values.
- Write its PMF.
- Find \(P(X=6)\) and \(P(X\le6)\).
- Find \(E[X]\) and \(\operatorname{Var}(X)\).
Answer
- \(X\sim\operatorname{Pascal}(4,0.8)\), with \(R_X=\{4,5,6,\ldots\}\).
- \(P(X=k)={k-1\choose3}(0.8)^4(0.2)^{k-4}\), for \(k=4,5,6,\ldots\).
- \(P(X=6)=0.16384\) and \(P(X\le6)=0.90112\).
- \(E[X]=4/0.8=5\) and \(\operatorname{Var}(X)=4(0.2)/(0.8)^2=1.25\).
Exercise 10 — Designing an inspection sample¶
A company performs inspection on shipments from suppliers to detect nonconforming products. Assume that a lot contains 1,000 items and exactly 10 are nonconforming.
- Using a binomial model with \(p=0.01\), what sample size is needed so that the probability of selecting at least one nonconforming item is at least 0.90?
- If the items are sampled without replacement, write the exact hypergeometric probability of selecting at least one nonconforming item in a sample of size \(n\).
- Find the smallest sample size that gives a probability of at least 0.90 under the hypergeometric model, and compare it with the binomial result.
Answer
- The binomial model requires a sample size of at least 230.
- The exact probability is \(1-\frac{{990\choose n}}{{1000\choose n}}\).
- The hypergeometric model requires a sample size of at least 205. Sampling without replacement increases the chance of finding a nonconforming item because the lot contains exactly 10 such items.
Exercise 11 — Valid PMF¶
Let
- Find \(c\) so that this is a valid PMF.
- Find \(P(X\in\{2,4,6\})\).
- Find \(P(X\ge3)\).
Answer
- Since \(\sum_{k=1}^{\infty}c/3^k=c/2=1\), \(c=2\).
- \(P(X\in\{2,4,6\})=182/729\).
- \(P(X\ge3)=1/9\).
The notebook ex1.ipynb can be used as a starting point for discrete-distribution calculations.