Unfair on purpose, and exactly as unfair as you set

Weighted Coin Flip

Pick any chance of heads from 1% to 99%, then flip. The weighting is applied to an unbiased random integer, so the long-run rate matches the number you configured.

Chance of Heads

Heads 70% · Tails 30%. Changing the weight clears the statistics so a run always describes one configuration.

Configured against observed

70%Configured Heads
Observed Heads
Difference
0Heads
0Tails
0Total flips

Streaks and expectation

0Current streak
0Longest streak
0.0Expected Heads
1 in 1.4Heads odds per flip

A weighted coin still produces streaks of the unlikely side. The observed percentage approaches the configured one as the run grows, not within the first few flips.

Method web-crypto-getRandomValues-v1 (version 1) · How results are selected

How the weighting is applied

Setting 70% draws an integer from 0 to 99 with rejection sampling, then reports heads for 0 through 69. Every one of the hundred buckets is equally likely, so exactly seventy of them mean heads. A 0% or 100% setting is not offered, because a coin with only one possible outcome is not a coin.

This matters more than it sounds: comparing a floating-point random value against0.7 introduces a tiny rounding error, and the integer threshold does not.

What weighting does not change

  • Flips stay independent; the coin has no memory of the previous result.
  • Streaks of the unlikely side still occur and are not a defect.
  • The animation still only reveals a result chosen before it started.
  • Nothing about the weight is sent anywhere; it lives in this page only.

Reading a biased coin honestly

The most common mistake with a weighted coin is expecting the observed split to match the configured one quickly. It does not. At a 70% setting, ten flips produce exactly seven heads only about 27% of the time, and anywhere from four to ten heads is unremarkable. What converges is the proportion: the absolute gap between observed and expected head counts tends to grow with the number of flips, while the percentage gap shrinks.

Use Add 100 flips a few times and watch both numbers at once. That contrast — a widening count difference alongside a narrowing percentage difference — is the law of large numbers doing exactly what it claims, and it is the part most explanations leave out.

Weighted coin questions

How does a weighted coin flip work?
Set the chance of heads to any whole percentage from 1 to 99. Each flip then draws an unbiased random integer from 0 to 99 using the browser Web Crypto API and reports heads when that integer falls below your configured percentage. Because the threshold is applied to an exact integer rather than a rounded decimal, the long-run rate matches the number you set.
Is a weighted coin flip still random?
Yes. Weighting changes the probability of each side, not the independence of the flips. A 70/30 coin still has no memory: it can produce a run of the 30% side, and each flip is unaffected by the ones before it.
Why does my observed percentage not match the weight I set?
Short runs deviate. With a 70% setting and ten flips, seven heads is the single most likely count but it happens only about 27% of the time. Add a hundred flips at a time and watch the observed percentage close in on the configured one; the gap shrinks in proportion, not in absolute count.
What is a weighted coin used for?
Teaching biased-coin probability and the binomial distribution, modelling an event that is not an even split such as a 70% chance of rain, giving one option a deliberate advantage in a game, and demonstrating that streaks appear even when the probabilities are uneven.

The exact sampling function is published in the randomness method, and the matching closed-form maths lives in the coin flip probability calculator.