Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 1.56 KB

exponential_decay.org

File metadata and controls

36 lines (25 loc) · 1.56 KB

Exponential Decay

The inspiration for this activity came from browsing twitter. @BridgetDunbar asked, “Is there a simulator out there for flipping a lot of coins at once?” I didn’t know of any that would give the count of all the heads and tails, so I coded a simple one for her.

import random


random.seed(1)
FLIPS = 200
heads = 0
tails = 0
for flip in range(FLIPS):
    flip = random.randint(0, 1)
    if flip == 0:
        heads += 1
    else:
        tails += 1

print(f"Number of heads: {heads}")
print(f"Number of tails: {tails}")

After a couple clarifying questions turns out she was trying to recreate this statistics activity.

./stats-activity.png

No worries, python can handle that easily! So I created a program in Google Colab that allows mimics the experiment. Then she asked for the ability to see the outcomes of multiple experiments. I added a second cell where the user can enter the number of times they would like to run the experiment it will construct a graph for each one. By letting python handle the calculations and graphing you can free up your mind for more interesting questions like, why does it make sense that this represents exponential decay? If you start with 256 coins, how many trials do you expect there to be in each experiment?