Skip to content
nonconvexcard

Recover Little's law from an event log

CodingIntermediate⏱ 1 hourAI Systemslittle's lawevent logoccupancymeasurement

Problem

Given arrival and departure timestamps for a set of requests, reconstruct the three quantities in Little's law and verify the identity numerically.

  1. number_in_system(arrivals, departures, times) — occupancy at each queried instant, with an item present on [ai,di)[a_i, d_i).
  2. time_average_number(arrivals, departures) — the exact time-average occupancy over [0,T][0,T] with TT the last departure, computed from the area identity rather than by sampling.
  3. littles_law_check(arrivals, departures) — returning LL, λ\lambda, WW and the residual L−λWL - \lambda W.

The residual should be zero to machine precision, not merely small.

Implement it, then check the implementation against something you can verify independently.

Write it

Solve it here7 tests · Python runs in your browser
⌘/Ctrl + ↵ to run · limit 60s · draft saved in this browser
7 tests will run against your code. The first run downloads the Python runtime — several megabytes, once per browser.

Hints

Hints — 0 of 2 revealed

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
Apply Little's law to a serving targetLLM OpsProofIntermediate30 min
Prove Little's law on a finite horizonAI SystemsProofIntermediate1 hour
Simulate M/M/1 and verify the utilisation wall runAI SystemsCodingIntermediate1 hour