ForHosting KIT · Developer Utilities

Coin toss streak probability calculator

This coin toss streak probability calculator finds the chance that at least one run of consecutive heads appears within a chosen number of fair tosses.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter the total toss count and the required streak length, and it evaluates every possible way the sequence can evolve without relying on simulation. The result includes both the event probability and its complement, making it useful for games, probability lessons, experiment planning, and checks of intuition about repeated independent trials.

What the calculator measures

The event measured here is at least one uninterrupted run of the requested length anywhere among the tosses. A run may begin on the first toss, finish on the last toss, or sit between tails. Longer runs also count: a sequence containing four consecutive heads satisfies a request for a three-head streak because it contains overlapping groups of three consecutive heads. The calculator does not ask for exactly that many total heads, and it does not require the streak to occur only once. Those are different probability questions. Every toss is assumed to be independent and fair, so heads and tails each have probability one half. For example, ten tosses with a target streak of three asks whether HHH appears at least once in any position across the ten outcomes. It does not matter how many additional heads occur elsewhere. If the requested streak exceeds the total toss count, the event cannot fit inside the experiment; this capability treats that mismatch as invalid input so configuration mistakes are visible rather than silently returned as an unhelpful result.

How the probability is calculated

Simply adding the probabilities for a streak starting at each possible position gives the wrong answer because candidate runs overlap. In HHHH, for example, a three-head run starts in two positions, but the outcome must be counted only once. This calculator avoids that double counting with dynamic programming. After every toss, it tracks the probability that the target has not appeared and that the current sequence ends with zero, one, two, or more consecutive heads, stopping one state short of the target length. A tail moves all surviving paths back to a trailing run of zero. A head advances each path to the next run length; any path that reaches the target is removed from the no-streak states. After all tosses, the surviving state probabilities are summed to obtain the chance of never seeing the requested run. Subtracting that value from one gives the probability of at least one streak. This method evaluates the event directly, is deterministic, and avoids the sampling error that comes with a Monte Carlo simulation.

How to interpret and use the result

The response reports probability as a number from zero to one, percent as the same result multiplied by one hundred, and probability_no_streak as the complementary event. A value of 0.5078125 means the requested run occurs in about 50.78125 percent of experiments conducted under the stated assumptions; it does not predict what a particular short sequence must do. Repeating an experiment many times should make its observed frequency approach the calculated probability, but random variation remains normal. Use the complement when planning around avoidance, such as estimating how often a game finishes without a long run. Compare several streak lengths to see how quickly rare patterns become plausible as the number of opportunities grows. Remember that the model is specifically for a fair, independent coin. A weighted coin, dependence between tosses, stopping rules, or a request for either heads or tails would require a different calculation. Inputs are bounded to one thousand tosses so the same pure algorithm remains responsive in the browser and through the API. For automated calls, each calculation costs $0.002; the page can also run it locally.

Check a probability lesson

Compare intuition with the exact chance of observing consecutive heads over a fixed classroom experiment.

Design a tabletop rule

Estimate how frequently a bonus triggered by several heads in a row will occur during play.

Plan repeated trials

Choose a toss count that makes a target run common enough to demonstrate without using simulation.

What does at least one streak mean?

It means the requested run appears anywhere one or more times. Any longer run also contains the requested streak and therefore counts.

Does this calculate exactly that many heads?

No. It calculates consecutive heads, regardless of how many heads appear outside the run. Use a binomial probability calculator for an exact total.

Why can I not set a streak longer than the toss count?

That run cannot fit within the experiment. The capability returns an invalid-input error to expose the inconsistent request.

Is the answer based on simulation?

No. A deterministic dynamic program accounts for overlapping possible runs and returns the mathematical probability without random sampling.

Does it support a biased coin, and what does the API cost?

No. Heads and tails are each assumed to have probability one half, and all tosses are independent. Each API request costs $0.002; you can also use the browser calculator on this page.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/coin-streak

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/coin-streak \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tosses":10,"streak":3}'
{
  "tosses": 10,
  "streak": 3
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.coin_streak",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_tosses1000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →