The displayed sum is less than 1 only because the infinite support was truncated at 20 failures.
Pediatrician recruitment example
A pediatrician asks couples to participate until 5 agree. Each couple agrees with probability \(p=0.20\). If exactly 15 couples are asked, there were 10 failures before the fifth success:
If instead \(T=X+r\) counts the total number of trials through the \(r\)th success, then \(E(T)=r/p\) and \(\operatorname{Var}(T)=\operatorname{Var}(X)\).
Code
r <-5p <-0.20mean_failures <- r * (1- p) / pvariance_failures <- r * (1- p) / p^2c(mean_failures = mean_failures,mean_total_trials = mean_failures + r,variance = variance_failures,sd =sqrt(variance_failures))
Quantiles and a simulation check (fictional extension)
Code
# Failures needed so there is at least 90% probability of having r successesq90_failures <-qnbinom(0.90, size =5, prob =0.20)q90_total_trials <- q90_failures +5set.seed(14270)simulated_failures <-rnbinom(100000, size =5, prob =0.20)c(q90_failures = q90_failures,q90_total_trials = q90_total_trials,simulated_mean =mean(simulated_failures),theoretical_mean =5*0.8/0.2)
Base R’s dnbinom(), pnbinom(), qnbinom(), and rnbinom() count failures before size successes. If a question gives the total trial number \(t\), convert it with \(x=t-r\).
Practice questions
A sale occurs with probability \(0.25\) on each independent call. Find the probability of exactly 8 failures before the third sale.
Find the probability that the third sale occurs by the 11th call.
Find the expected number and variance of failures before the third sale.
Find the expected total number of calls through the third sale.
NoteCheck your answers
dnbinom(8, size = 3, prob = 0.25) gives approximately \(0.0704\).
The condition is \(X\leq8\), so pnbinom(8, 3, 0.25) gives approximately \(0.5448\).
The mean is \(3(0.75)/0.25=9\) and the variance is \(3(0.75)/0.25^2=36\).