Longest Run of Heads in 100 Coin Flips

If you flip a coin 100 times in a row, what’s the longest run of heads or tails you will see? This is surprisingly difficult to answer with a mathematical equation but is a cinch for #simulation in #rstats using #shiny.

Running the experiment 10,000 times, we can see that the mode (most common value) is 4 heads in a row (about 26% probability). On average, you’ll see a run of 5 heads out of the 100 coin flips. (image in comments)

So what does this have to do with #supplychain? Many activities in supply chain and #logistics can be thought of as a coin flip – although not necessarily with 50/50 odds. Will my truck show up during its appointment window? Will demand today exceed my inventory, leading to a stockout?  By thinking of these events as coin flips, you can use the power of #statistics and #predictiveanalytics to drive improvements in your supply chain.

To try it for yourself, go to https://datadrivensupplychain.shinyapps.io/stats_shiny/ and click on “Coin Flip Simulation”. Edit the number of coins you want to flip, number of times you want to repeat the experiment, and the probability of a coin coming up “heads” (default to 0.5, or 50%, for a fair coin). Then click “Run Coin Flip Experiment” and wait for results.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s