Probability of streaks

Anything you want to talk about.
User avatar
Posts: 1372
Joined: 26 May 2012, 22:26

Probability of streaks

Postby Alundaio » 21 Oct 2014, 19:18

Here are two scripts, one in perl or lua, for calculating the probability of streaks. The purpose of these scripts is to calculate odds for various probabilities. It's the same method risk calculators or odd calculators use to determine probability of streaks. I noticed quite a few people don't understand probability (Like people on Steam forums for just about any video game that shows probability) and maybe this will help someone here. Or maybe you are just a crazy gambler, :P.

How to use:

You can run them from command prompt if you have either Active Perl installed or lua. The easiest way is to Shift+Right-Click in a folder containing the script and clicking "Open Command Window Here" within the menu. Then you can easily type the filename to run it.

There are only 3 variables you need to alter at the top of the script. Change these to your liking.


Coin Flipping. Say you have a fair coin and want to know the probability of having a streak of 2 tails in a row if you flipped the coin 10 times. Since there are only 2 finite outcomes the probability would be 0.5 or 1/2 for landing on either heads or tails.

We would alter the variables like this:

Code: Select all

Probability = 0.5
events = 2
trials = 10

If you ran the code, it would spit out:

Code: Select all

Probability of 2 events of probability 0.5 in a row in 10 trials = 0.826171875
or 0.2104189125296 to 1

What this means is that there is a 82% chance that you will see 2 tails in a row if you flipped a coin ten times which is 0.2104189125296 to 1 odds.

Another example, PRNG hit chance. Say you have an 85% chance hit on a target which is a 15% chance to miss. What is the probability you will miss 3 times in a row out of 100 shots?

Code: Select all

local probability = 0.15;      -- Chance of occurrence
local events = 3;            -- Number of occurrences in a row
local trials = 100;            -- Number of trials

Probability of 3 events of probability 0.15 in a row in 100 trials = 0.247583336
or 3.0390440489151 to 1

As you can see from the output, you have a 25% chance to see 3 misses in a row out of 100 shots.


There is a misconception with probability of streaks. Often times people will calculate this wrongly. For example, one would will wrongly calculate 0.5*0.5 (25%) for my coin flipping example. This is wrong because it assumes the chances for flipping another tails goes down. The proper way is to use Fibonacci n-step number.

Streaks are common in randomness. What would be strange if there were no streaks at all. The more trials that occur the more often you will see streaks at an increasing length.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

Return to “Off-Topic”

Who is online

Users browsing this forum: No registered users and 1 guest