Rate-distortion trade-off for a clip.
Uncompressed 8-bit 4:4:4 video needs 24·W·H·fps bit/s. A compressed file has size bitrate × duration / 8; the compression ratio is raw divided by compressed. A useful quality indicator is bits per pixel bpp = bitrate/(W·H·fps).
Rate-distortion theory says PSNR grows roughly logarithmically with the bit budget: about 6 dB per doubling of rate per pixel at high rates. This page uses PSNR ≈ 27 + 6·log2(bpp·e/0.1) clipped to 20-52 dB, where the codec multiplier e models that newer codecs reach the same quality with less rate (HEVC ≈ 1.5, AV1 ≈ 2). Above about 40 dB differences are hard to see.
Real PSNR depends on content (a talking head compresses far better than football) and on encoder settings; the 27 dB offset is an illustrative calibration, not a measurement.
File size is computed in two independent ways (bitrate x time, and bits-per-pixel x pixels x frames x time) and the results must agree to within 1e-9 relative error. The result is shown live under the chart and turns red if the agreement fails.
All random draws come from a seeded 32-bit generator (mulberry32) and Gaussian variates from the Box-Muller transform, so a given seed always produces the same sample on every device; Re-run random seed advances the seed deterministically. Deterministic curves are evaluated on a fixed grid and integrated, where needed, with a fixed-step fourth-order Runge-Kutta scheme whose local error scales with the fifth power of the step; the step sizes used here keep the error far below the drawn line width.
The tiles under the chart are recomputed on every slider move. Quantities labelled exact or analytic come from a closed-form expression; quantities labelled simulated come from the random sample and fluctuate around the exact value by an amount that shrinks as the sample size grows (roughly as one over the square root of the sample size). The green or red box is the automated agreement test between the two.
This page is an educational model, not a decision tool. It is meant to build intuition for how a handful of parameters shape an outcome and how a stated formula can be checked against an independent numerical experiment. Numbers are illustrative unless a unit is given, and results must not be used for real engineering, medical, financial or legal decisions. If you notice a result that contradicts the stated formula, the built-in check is the first place to look: it is designed to fail loudly instead of hiding a disagreement, and a failing check on a sensible parameter set would be a bug worth reporting.
Why does the simulated value never match the exact one perfectly? Because a finite random sample has sampling error; the check box tests that the difference is no larger than four standard errors, which a correct model fails only about once in sixteen thousand runs.
Why are some sliders limited to a narrow range? Outside those ranges the formula is still valid mathematically but the plain-language interpretation stops making sense, or the chart would become unreadable.
Can I embed or share a state? The page keeps no hidden state: the sliders, the seed and the formulas fully determine every number you see, so a screenshot of the sliders is enough to reproduce a result.
Does the chart work on a phone? Yes. The canvas resizes with its container, scales to the device pixel ratio (capped at 2 for smooth drawing), and the controls stack above the chart on narrow screens.