probabilistic warm-up
A funny exercise that serves as pretext for first lines in Python.
5/8/20241 min read
What is the probability of getting exactly 50 heads when a coin is tossed 100 times?
Let's begin our journey exploring Python's capabilities with this classic problem! We'll assume that heads and tails have the same probability of occurrence, p = 0.5, and let the number of tosses be n = 100.
With a fair coin, one might expect the number of heads and tails to be roughly equal. So out of n trials, we could anticipate getting around n/2 tails and n/2 heads. However, the word 'exactly' in the initial question adds an intriguing dimension: Is the probability of getting exactly n/2 tails and n/2 heads equal to 1/2? Is it close to 1/2? Or is it something entirely different?
Let's use Python to simulate this experiment:




pythonist.io
Mathematics, machine learning and artificial intelligence with Python.
feedback
© 2024. All rights reserved.