Skip to content
AZ Tools

Coin Flip Simulator

Run a coin-flip experiment of anywhere from a single toss to 10,000 flips in one click. The bias slider sets the probability of heads between 1% and 99%, so you can model an unfair coin as easily as a fair one. After each run you get the heads and tails counts, the observed heads ratio alongside the expected count (flips × probability), and the longest streak of each side; for runs of up to 1,000 flips the full H/T sequence is rendered so you can eyeball the streaks and copy them out. Flips are generated client-side with the browser's Math.random() — a fast pseudorandom generator that is statistically fine for simulations, classroom demos, and building probability intuition, but not suitable for lotteries or anything adversarial. The statistics are a nice illustration of probability in action: the ratio converges toward the slider setting as the sample grows (the law of large numbers), yet the longest run keeps growing roughly like log2 of the number of flips — genuine randomness is far streakier than most people expect.

Math.random()-based — fine for stats / demos, not for cryptographic draws.

How to use

  1. Enter how many flips to simulate (1 to 10,000 — values outside this range are clamped).
  2. Set the probability of heads with the bias slider; leave it at 50% for a fair coin.
  3. Click Flip to run the whole experiment at once.
  4. Compare the observed heads count and ratio with the expected heads (flips × probability).
  5. For runs of 1,000 flips or fewer, review or copy the full H/T sequence shown below the statistics.

Frequently asked questions

Why does a fair coin produce such long streaks?
In a fair sequence of N flips the longest run of one side is typically around log2(N): about 7 in 100 flips, and 10 or more in 1,000. A long streak is expected behavior, not evidence the coin is rigged — human-invented 'random' sequences are usually detectable precisely because they avoid streaks like this.
How close should the heads ratio land to the slider value?
The heads count follows a binomial distribution with standard deviation √(n·p·(1−p)). For a fair coin that means deviations of roughly ±5 percentage points are normal at 100 flips, but only about ±0.5 at 10,000 — increase the sample size and watch the ratio tighten.
Is this cryptographically random?
No. Flips come from Math.random(), a fast pseudorandom generator. That's fine for statistics, demos, and games, but for raffles, security decisions, or anything where a motivated party benefits from bias, use a cryptographically secure or verifiable random source instead.
Why doesn't the sequence appear for big runs?
The raw H/T string is rendered only for runs of up to 1,000 flips to keep the page responsive. The statistics, however, are always computed over the full run, so a 10,000-flip experiment still reports exact counts and longest streaks.
Can I use it for a single decision flip?
Yes — set flips to 1 and click. Each click is an independent experiment: previous results have no influence on the next one, so a string of heads does not make tails 'due' (that's the gambler's fallacy).

Related tools