```{r} #| label: setup #| include: false set.seed(2026) library(ggplot2) ``` ## π¬ The Idea in 3 Minutes ::: {style="text-align:center"} [Watch this short intuition video before (or after) the slides. Captions: CC button.]{style="font-size:22px"} ::: --- ## π― Learning Objectives ::: {style="font-size: 32px"} By the end of this lecture, you will be able to: - **Recognise** a waiting-time experiment: the successes are fixed, the number of trials is random - **Compute** geometric probabilities $q^{y-1}p$ and tail probabilities $P(Y > a) = q^a$ - **Explain** the memoryless property, and why "overdue" is not a probability argument - **Apply** the negative binomial distribution to the trial on which the $r$th success occurs - **Use** $E(Y) = r/p$ and $V(Y) = rq/p^2$ to plan a cost or a time budget ::: --- ## πΊοΈ Where We Are ::: {style="font-size: 32px"} **Wackerly Β§3.5β3.6** Wednesday: the binomial β fixed $n$, two outcomes, constant $p$, independent trials, and $Y$ **counts the successes**. We ended on the question: *what happens when the number of trials is the random quantity?* ::: {.fragment} Today's answer: **fix the number of successes** and count the trials. How many calls until the first sale? How many wells until the second discovery? ::: ::: {.fragment} Same trials as Wednesday β two outcomes, constant $p$, independent. Only the stopping rule changes. ::: ::: --- ## π Definition 3.8: Geometric ::: {style="font-size: 30px"} $Y$ = the number of the trial on which the **first** success occurs. The event $(Y = y)$ is the single sample point $FF\cdots FS$, with $y-1$ failures before the success, so by independence $p(y) = q^{y-1}p$. ::: {.callout-important} ## Definition 3.8 $Y$ has a **geometric probability distribution** if and only if $$p(y) = q^{y-1}p, \qquad y = 1, 2, 3, \ldots, \quad 0 \le p \le 1.$$ ::: ::: {.fragment} Each ratio $p(y)/p(y-1) = q < 1$: the most likely value is always $y = 1$. ::: ::: --- ## π Theorem 3.8, on the Broker's Phone ::: {style="font-size: 30px"} ::: {.callout-important} ## Theorem 3.8 If $Y$ has a geometric distribution, $\;\mu = E(Y) = \dfrac{1}{p}\;$ and $\;\sigma^2 = V(Y) = \dfrac{1-p}{p^2}$. ::: **Proof idea:** $\sum_y y q^{y-1} = \frac{d}{dq}\sum_y q^y = \frac{d}{dq}\frac{q}{1-q} = \frac{1}{p^2}$; multiply by $p$. ::: {.fragment} A junior broker in Baku cold-calls prospects; each call opens an account with $p = 0.08$. **First account on call 5:** $P(Y = 5) = (0.92)^4(0.08) = 0.0573$. ::: ::: {.fragment} $E(Y) = 1/0.08 = 12.5$ calls and $\sigma = \sqrt{0.92}/0.08 = 11.99$: the spread is as large as the mean. ::: ::: --- ## π The Memoryless Property ::: {style="font-size: 30px"} A risk desk's early-warning indicator flashes a **crash signal** on any trading day with probability $p = 0.02$, independently. $Y$ = the day of the first signal. "No signal in $a$ days" means $a$ failures in a row, so $P(Y > a) = q^a$ (Exercise 3.71a): $P(Y > 20) = (0.98)^{20} = 0.6676$. ::: {.fragment} Now suppose 30 quiet days have already passed: $$P(Y > 50 \mid Y > 30) = \frac{q^{50}}{q^{30}} = q^{20} = 0.6676$$ ::: ::: {.fragment} **The past 30 days changed nothing** (Exercise 3.71b). A geometric process is never "overdue": each day starts the wait afresh, which is exactly what independent trials promise. ::: ::: --- ## π Definition 3.9: Negative Binomial ::: {style="font-size: 30px"} $Y$ = the number of the trial on which the **$r$th** success occurs. Let $A$ = {first $y-1$ trials hold $r-1$ successes} and $B$ = {trial $y$ is a success}. They are independent, and $P(A)$ is Wednesday's binomial: $$p(y) = P(A)P(B) = \binom{y-1}{r-1}p^{r-1}q^{y-r} \times p$$ ::: {.callout-important} ## Definition 3.9 $$p(y) = \binom{y-1}{r-1}p^{r}q^{y-r}, \qquad y = r, r+1, r+2, \ldots, \quad 0 \le p \le 1.$$ ::: With $r = 1$ it is the geometric distribution. ::: --- ## π’οΈ Exploration Licences ::: {style="font-size: 30px"} A company holding Caspian exploration licences needs **two** commercial discoveries before a pipeline tie-in pays. Each appraisal well is commercial with probability $p = 0.25$, independently. ::: {.fragment} **Second discovery on the sixth well** ($r = 2$, $y = 6$): $$P(Y = 6) = \binom{5}{1}(0.25)^2(0.75)^4 = 5 \times 0.0625 \times 0.3164 = 0.0989$$ ::: ::: {.fragment} **The budget covers eight wells.** $P(Y \le 8)$ is the chance of *at least two* successes in 8 binomial trials: $$1 - (0.75)^8 - 8(0.25)(0.75)^7 = 1 - 0.1001 - 0.2670 = 0.6329$$ ::: ::: --- ## π» The Same Numbers in R ```{r} #| label: in-r #| code-fold: false # R counts FAILURES before the r-th success, so its first argument is y - r dgeom(5 - 1, prob = 0.08) # broker: P(Y = 5) 1 - pgeom(10 - 1, prob = 0.08) # broker: P(Y > 10) dnbinom(6 - 2, size = 2, prob = 0.25) # wells: P(Y = 6) pnbinom(8 - 2, size = 2, prob = 0.25) # wells: P(Y <= 8) ``` ::: {style="font-size: 28px"} Wackerly's $Y$ counts **trials**; R's counts **failures**, $Y^\star = Y - r$. Forget the shift and every answer is one trial off. ::: --- ## π Theorem 3.9: Collections ::: {style="font-size: 30px"} ::: {.callout-important} ## Theorem 3.9 $$\mu = E(Y) = \frac{r}{p} \qquad\text{and}\qquad \sigma^2 = V(Y) = \frac{r(1-p)}{p^2}.$$ ::: A collections agent phones overdue borrowers; each call secures a payment with $p = 0.3$. The shift ends at the **fourth** paying debtor: $E(Y) = 4/0.3 = 13.33$ calls, $V(Y) = 4(0.7)/0.09 = 31.11$. ::: {.fragment} Each call takes 4 minutes, and each payment adds 6 minutes of paperwork, so $T = 4Y + 24$: $$E(T) = 4(13.33) + 24 = 77.3 \text{ min}, \qquad \sigma_T = 4\sqrt{31.11} = 22.3 \text{ min}$$ ::: ::: --- ## π One Payment, or Four ```{r} #| label: nb-figure #| echo: false #| fig-width: 11 #| fig-height: 4.4 p <- 0.3 yy <- 1:30 df <- rbind( data.frame(y = yy, prob = dnbinom(yy - 1, 1, p), r = "r = 1 (geometric)"), data.frame(y = yy, prob = ifelse(yy >= 4, dnbinom(pmax(yy - 4, 0), 4, p), 0), r = "r = 4 (negative binomial)")) mu <- data.frame(r = c("r = 1 (geometric)", "r = 4 (negative binomial)"), m = c(1 / p, 4 / p)) ggplot(df, aes(y, prob)) + geom_col(width = 0.85, fill = "#8ba3c7") + geom_vline(data = mu, aes(xintercept = m), colour = "#8b2635", linewidth = 1.1) + facet_wrap(~ r, nrow = 1) + scale_x_continuous(breaks = seq(0, 30, 5), minor_breaks = NULL) + labs(x = "Call on which the shift's target is reached, y", y = "p(y)") + theme_minimal(base_size = 20) ``` ::: {style="font-size: 28px"} The geometric always peaks at $y = 1$. Ask for four successes and the peak moves right and the distribution spreads out; the red lines mark $r/p = 3.33$ and $13.33$. ::: --- ## π§ Think-Pair-Share ```{r} #| label: tps-timer #| echo: false # The timer is the only thing in this deck that needs a package beyond base R. # Guarded so a machine without it renders the deck anyway, with a static # figure in the same corner, rather than halting the whole build. if (requireNamespace("countdown", quietly = TRUE)) { countdown::countdown(minutes = 4, seconds = 0, top = 0, right = 0, font_size = "2em", warn_when = 30) } else { htmltools::HTML(paste0( '4:00
')) } ``` ::: {style="font-size: 30px"} An importer files customs declarations one after another at a Baku border post. Each is picked for **physical inspection** with probability $0.1$, independently. **Four minutes, in pairs:** 1. What is the probability the first inspection falls on the third declaration? 2. What is the probability of no inspection in the first ten? 3. On average, on which declaration does the **third** inspection fall? What is $P(\text{third inspection on declaration } 10)$? ::: --- ## β
Think-Pair-Share: Solution ::: {style="font-size: 30px"} 1. Geometric, $p = 0.1$: $P(Y = 3) = (0.9)^2(0.1) = 0.081$ 2. Tail: $P(Y > 10) = (0.9)^{10} = 0.3487$ ::: {.fragment} 3. Negative binomial, $r = 3$: $E(Y) = 3/0.1 = 30$th declaration on average, and $$P(Y = 10) = \binom{9}{2}(0.1)^3(0.9)^7 = 36 \times 0.001 \times 0.4783 = 0.0172$$ ::: ::: {.fragment} **The habit:** first ask what is fixed. Fixed trials, count successes: binomial. Fixed successes, count trials: geometric or negative binomial. ::: ::: --- ## π Quiz #1: Expected Wait {.quiz-question} A compressor station trips on any given day with probability $0.04$, independently. On average, on which day does the first trip occur? - [Day $25$]{.correct data-explanation="β
Theorem 3.8: E(Y) = 1/p = 1/0.04 = 25. Rarer events mean longer waits, in inverse proportion."} - Day $24$ - Day $4$ - Day $1$, because $p(1)$ is the largest probability --- ## π Quiz #2: Overdue? {.quiz-question} The crash indicator ($p = 0.02$ per day) has been quiet for 40 days. What is the probability it stays quiet for the **next** 10? - [$(0.98)^{10} = 0.817$]{.correct data-explanation="β
Memoryless: P(Y > 50 | Y > 40) = q^50 / q^40 = q^10. The 40 quiet days carry no information about the next 10."} - $(0.98)^{50} = 0.364$ - $(0.98)^{40} = 0.446$ - Less than $0.817$, because a signal is now overdue --- ## π Key Formulas ::: {style="font-size: 30px"} | | Statement | |---|---| | Definition 3.8 (geometric) | $p(y) = q^{y-1}p, \quad y = 1, 2, \ldots$ | | tail, memoryless | $P(Y > a) = q^a, \quad P(Y > a+b \mid Y > a) = q^b$ | | Theorem 3.8 | $E(Y) = 1/p, \quad V(Y) = (1-p)/p^2$ | | Definition 3.9 (negative binomial) | $p(y) = \binom{y-1}{r-1}p^r q^{y-r}, \quad y = r, r+1, \ldots$ | | Theorem 3.9 | $E(Y) = r/p, \quad V(Y) = r(1-p)/p^2$ | | in R | `dgeom(y-1, p)`, `dnbinom(y-r, r, p)` | ::: --- ## π Summary ::: {style="font-size: 30px"} - Binomial fixes the trials; geometric and negative binomial fix the successes and count the trials - The geometric $p(y) = q^{y-1}p$ always peaks at $y = 1$, with mean $1/p$ - "No success in $a$ trials" is $q^a$ β a tail probability with no sum - Memoryless: a wait that has already run gives no discount on the rest of it - The negative binomial is a binomial on the first $y - 1$ trials, times one final success - $r/p$ and $rq/p^2$ turn a target into a time or cost budget ::: --- ## π Practice Problems ::: {style="font-size: 28px"} **Wackerly, 7th edition** - Β§3.5: Exercises 3.67, 3.70, 3.71, 3.73, 3.75, 3.81 - Β§3.6: Exercises 3.90, 3.91, 3.93, 3.97 **Week 6, Problem Set 2** is open now and closes **Sunday 25 October at 23:59** on WeBWorK, covering Β§3.5β3.6. **Midterm I is on 24 October**, covering Chapters 1β3 (Β§Β§3.1β3.8). **Next class:** Wednesday 21 October β the hypergeometric and Poisson distributions, and the review for Midterm I (Wackerly Β§3.7β3.8). ::: --- ## π Thank You Β· β Questions ::: {style="font-size: 30px"} **Dr. Samir Orujov** Β· π§ sorujov@ada.edu.az Β· π’ D325 Β· π Wed 16:00 β 18:00 Β· **sorujov.net/teaching** - Is the time until a loan defaults plausibly memoryless, or does a loan's age matter? - Why can the most likely value of a geometric variable be $1$ when its mean is $12.5$? - If the success probability drifts during a shift, which assumption of today's models fails first? :::