Checking if tossing a fair coin n times leads to probability of heads converging to 1/2, when n is very large(tends to infinity) using python. The program depicts the strong law of large numbers
Sometimes the value of n i.e. number of times the coin is tossed may be too small to get the accurate idea of the value of probability of heads while tossing a fair coin, but when we increase the value of n (as n tends to infinity), it can be observed that the value of probability of heads in the actual world tends to that of the theoretical world i.e. 1/2. This is a proof of the strong law of large numbers. This law states that the actual probability of an experiment tends to its theoretical probability for example tossing of a fair coin, getting a six in a roll of die.
To prove the above statement we can use the following steps:
1. First we will import the library random in python which we basically use to generate random numbers
2. We will generate 0's and 1's and assign those numbers to the variable toss
3. We assign the value 1 to heads and 0 to tails
4. Then we ask the user to input N i.e. the number of times the coin is tossed
5. When the value of N is too small the prabability of heads is not usually 0.5 (theoretical probability), when we increase the value of N the probability of heads converges to 0.5
6. This python program depicts the strong law of large numbers.
Submitted by Ayush Chauhan (AyushChauhan07)
Download packets of source code on Coders Packet
Comments