1/17
Learn

Bayes' rule and waiting times, the way the rounds ask

Netflix data science candidates report a Bayes' rule calculation in the statistics round (2 reports), and an OpenAI coding round asked for the expected number of iterations of a function that loops at random (1 source). This lesson's practice problem puts both in code, in three levels:

  1. posterior(prior, sensitivity, false_positive_rate): the chance an order is fraud once a check flags it. Then update(prior, results), which applies several independent results in order, positive or negative.
  2. expected_tries(p), expected_tries_for(successes, p) and coupon_collector(n): how long you wait for a success, for several, and for every one of n kinds.
  3. make_rand7(rand5): a fair 1 to 7 from a fair 1 to 5.
CallReturns
posterior(0.01, 0.95, 0.05)0.161: even after a flag, the order is more likely good
expected_tries(0.25)4.0
coupon_collector(10)29.3
make_rand7(rand5)(), many times1 to 7, each a seventh of the time

The lesson works on one shop throughout: a fraud check, a label printer, coupon codes and patch designs. It goes from conditional probability to Bayes' rule in odds form, then expected values, waiting times and rejection sampling. Eight steps end with a small task in the editor.