Sheldon Ross 10: Exercise 2.02

sheldon ross 10 exercise 2.02_heads and tails_cropped

Question: Let X represent the difference between the number of heads and the number of tails obtained when a coin is tossed n times. What are the possible values of X?


Solution:

This is a modified binomial distribution. We are looking at the differences here instead of just the counts. This means that the random variable X ranges from -n to n in steps of 2. Here is one way to design the algorithm

  • Perform a series of ‘n’ bernoulli operations (the outcome of each of the operation is either 0 or 1)
    • 0 0 0 0 1 0 0 0 1 0
  • Then, count the number of fails and passes
    • 8 & 2
  • Find the difference between the passes and fails
    • -6
  • Repeat steps one through three and observe the distribution

Simulation:

We have seen the algorithm in the solution section and the same will be applied in the code. The charts and the code are given below. Here I have chosen the value of the n = 100. Observer how the values -100 to 100 in increasing steps of 2 are only possible.


End of the Post 🙂


.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.