Question

In: Statistics and Probability

Use python simulations to answer the following questions. You should be able to make minor modifications...

Use python simulations to answer the following questions. You should be able to make minor modifications to previous simulations to estimate these probabilities:

1) Suppose the pocket contains one fair coin and one two-headed coin. Find the approximate probability that the coin is fair given that it came up heads on the first flip.

2) Suppose the pocket contains one fair coin and one two-headed coin. Find the approximate probability that the coin is fair given that it came up heads on the first two flips.

3) Repeat part 1 if her pocket contains two fair coins and one two-headed coin.

4) Repeat part 2 if her pocket contains two fair coins and one two-headed coin.

Solutions

Expert Solution

1) Let F be the even that the coin picked is fair, 2H be the event that the coin picked is 2 headed.

Assuming that the coins are picked at random, the probability that the coin picked is fair is P(F) =0.5 and the probability that coin picked is 2 headed is P(2H) = 0.50

Let H be the event that the coin picked came heads up on the first flip.

If the coin is fair, the probability that it comes up heads is 0.50. If it is a 2 headed coin the probability that it comes up heads is 1 (always it comes up heads).

The conditional probability that heads in the first flip given that it is a fair coin is

P(H|F) = 0.50

The conditional probability that heads in the first flip given that it is a 2H coin is

P(H|2H) = 1

The probability that the coin is fair given that it came up heads on the first flip is

First these

Python code with comments to simulate this

#get this output

this is close to the theoretical probability 0.3333

2) Let F be the even that the coin picked is fair, 2H be the event that the coin picked is 2 headed.

Assuming that the coins are picked at random, the probability that the coin picked is fair is P(F) =0.5 and the probability that coin picked is 2 headed is P(2H) = 0.50

Let HH be the event that the coin picked came heads up on the first 2 flips.

If the coin is fair, the probability that it comes up heads is 0.50. If it is a 2 headed coin the probability that it comes up heads is 1 (always it comes up heads).

The conditional probability that heads in the first 2 flips given that it is a fair coin is

P(HH|F) = 0.50*0.50=0.25

The conditional probability that heads in the first 2 flips given that it is a 2H coin is

P(HH|2H) = 1*1=1

The probability that the coin is fair given that it came up heads on the first 2 flips is

Python code is below

get this output

this is close to the theoretical probability of 0.20

3) Let F be the even that the coin picked is fair, 2H be the event that the coin picked is 2 headed.

Assuming that the coins are picked at random, the probability that the coin picked is fair is P(F) =2/3 and the probability that coin picked is 2 headed is P(2H) = 1/3

Let H be the event that the coin picked came heads up on the first flip.

If the coin is fair, the probability that it comes up heads is 0.50. If it is a 2 headed coin the probability that it comes up heads is 1 (always it comes up heads).

The conditional probability that heads in the first flip given that it is a fair coin is

P(H|F) = 0.50

The conditional probability that heads in the first flip given that it is a 2H coin is

P(H|2H) = 1

The probability that the coin is fair given that it came up heads on the first flip is

First these

Python code is below

get this output

this is close enough to the theoretical probability of 0.50

4) Let F be the even that the coin picked is fair, 2H be the event that the coin picked is 2 headed.

Assuming that the coins are picked at random, the probability that the coin picked is fair is P(F) =2/3 and the probability that coin picked is 2 headed is P(2H) = 1/3

Let HH be the event that the coin picked came heads up on the first 2 flips.

If the coin is fair, the probability that it comes up heads is 0.50. If it is a 2 headed coin the probability that it comes up heads is 1 (always it comes up heads).

The conditional probability that heads in the first 2 flips given that it is a fair coin is

P(HH|F) = 0.50*0.50=0.25

The conditional probability that heads in the first 2 flips given that it is a 2H coin is

P(HH|2H) = 1*1=1

The probability that the coin is fair given that it came up heads on the first 2 flips is

Python code is below

get this output

This is close enough to the theoretical probability of 0.3333

-------------------------

The code in text format (the tabs may not be presents)

import numpy as np

#define a function to pick fair coin with probability p
def pickCoin(p):
#get a uniform random number in the interval (0,1)
u=np.random.random()
# pick fair coin if u<0.5 else 2 headed coin
if u<p:
return('F')
else:
return('2H')
#function to toss the coin n times and observe the result
def tossCoin(Type,n):
#set the probability of getting a head
if Type=='F':
p=0.5
else:
p=1
#variable to hold the result
r=''
#toss the coin n times
for i in range(n):
#get a uniform random number in the interval (0,1)
u=np.random.random()
# heads if u<p else tails
if u<p:
r=r+'H'
else:
r=r+'T'
return(r)

#part 1) the approximate probability that the coin is fair given that it came up heads on the first flip.
# set the seed for the random number generator
np.random.seed(123)
# set the number of simulations
N=10000
#initialize a variable to hold the toss
toss=[]
#simulate for N runs
for i in range(N):
#choose the coin, with probability of choosing a fair coin=0.5
coin=pickCoin(0.5)
#toss it one time
r=tossCoin(coin,1)
#if it is heads
if r=='H':
#then add 1 to toss if the coin is Fair
if coin=='F':
toss.append(1)
else: #else add a 0
toss.append(0)
#Calculate the conditional probability
prob=sum(toss)/len(toss)
print("probability that the coin is fair given that it came up heads on the first flip is %.4f "%prob)

#part 2) the approximate probability that the coin is fair given that it came up heads on the first two flips
# set the seed for the random number generator
np.random.seed(123)
# set the number of simulations
N=10000
#initialize a variable to hold the toss
toss=[]
#simulate for N runs
for i in range(N):
#choose the coin, with probability of choosing a fair coin=0.5
coin=pickCoin(0.5)
#toss it one time
r=tossCoin(coin,2)
#if it is 2 heads
if r=='HH':
#then add 1 to toss if the coin is Fair
if coin=='F':
toss.append(1)
else: #else add a 0
toss.append(0)
#Calculate the conditional probability
prob=sum(toss)/len(toss)
print("probability that the coin is fair given that it came up heads on the first two flips is %.4f "%prob)

#part 3) Repeat part 1 if her pocket contains two fair coins and one two-headed coin.
# set the seed for the random number generator
np.random.seed(123)
# set the number of simulations
N=10000
#initialize a variable to hold the toss
toss=[]
#simulate for N runs
for i in range(N):
#choose the coin, with probability of choosing a fair coin=2/3
coin=pickCoin(2/3)
#toss it one time
r=tossCoin(coin,1)
#if it is heads
if r=='H':
#then add 1 to toss if the coin is Fair
if coin=='F':
toss.append(1)
else: #else add a 0
toss.append(0)
#Calculate the conditional probability
prob=sum(toss)/len(toss)
print("probability that the coin is fair given that it came up heads on the first flip is %.4f "%prob)
  
#part 4) Repeat part 2 if her pocket contains two fair coins and one two-headed coin.
# set the seed for the random number generator
np.random.seed(123)
# set the number of simulations
N=10000
#initialize a variable to hold the toss
toss=[]
#simulate for N runs
for i in range(N):
#choose the coin, with probability of choosing a fair coin=2/3
coin=pickCoin(2/3)
#toss it one time
r=tossCoin(coin,2)
#if it is 2 heads
if r=='HH':
#then add 1 to toss if the coin is Fair
if coin=='F':
toss.append(1)
else: #else add a 0
toss.append(0)
#Calculate the conditional probability
prob=sum(toss)/len(toss)
print("probability that the coin is fair given that it came up heads on the first two flips is %.4f "%prob)


Related Solutions

Use at least 50000 simulations to answer the following questions. In the game of craps, the...
Use at least 50000 simulations to answer the following questions. In the game of craps, the shooter rolls two dice and wins if the sum of the dice is 7 or 11 ("natural"); he loses if the sum is 2,3, or 12 (craps). If the sum is 4, 5, 6, 8, 9, or 10, then the result is not yet decided. He must roll the dice again and again, as often as is necessary until the initial sum, be it...
You should be able to answer each of the following questions in a just a few...
You should be able to answer each of the following questions in a just a few sentences. Graphs or figures might be good to include if they help you to make a better argument or to explain your answer more clearly. 3. Grandma promises to sneak you some bourbon while your parents are cleaning up the Thanksgiving dishes, but only if you can impress her with something you learned in your economics class. Carefully explain to Grandma why the short...
You should be able to answer the following questions after studying “Error Analysis of a Statistical...
You should be able to answer the following questions after studying “Error Analysis of a Statistical Sample”, found in the Appendices. a) What is the difference between “random uncertainty” and “systematic uncertainty”? Provide examples of each. b) How do you calculate the uncertainty in a set of values that fluctuate randomly about some mean value? c) What is the formula for the standard deviation of a sample? What information does the standard deviation of a set of data provide? d)...
Major car manufacturers make use of computer simulations to experiment with possible plant layouts. The simulations...
Major car manufacturers make use of computer simulations to experiment with possible plant layouts. The simulations are designed to reflect stochastic effects such as different demand patterns, chance variations in processing times and breakdowns. Hence the results of running a simulation to calculate shifts’ production rates need to be analysed using appropriate statistical methods. Often these computer simulations are quite complex with quite long runtimes, and hence there is an interest in using as few runs of the simulation as...
Please answer all the questions. Thank you Use the following data to answer the questions below:...
Please answer all the questions. Thank you Use the following data to answer the questions below: Column 1 Column 2 Column 3 Y in $ C in $ 0 500 500 850 1,000 1,200 1,500 1,550 2,000 1,900 2,500 2,250 3,000 2,600 What is mpc and mps? Compute mpc and mps. Assume investment equals $ 100, government spending equals $ 75, exports equal $ 50 and imports equal $ 35. Compute the aggregate expenditure in column 3. Draw a graph...
Please answer the following questions. You should use between 200 to 300 words for each. 1.      What...
Please answer the following questions. You should use between 200 to 300 words for each. 1.      What is the principle of complementarity? Giving one example from each the following 4 different organizational levels, cells, tissues, organs, and organ systems, show how you have understood the principle of complementarity in the human body. 2.      What is homeostasis? Explain how the whole body contributes to the homeostasis of body pH. Refer to all the body systems, if a body system is not involved you...
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to...
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to answer all parts! How can international trade enhance economic efficiency? How can immigration enhance economic efficiency? Who might be made worse off because of international trade and/or immigration?
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to...
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to answer all parts! What does price elasticity of supply/demand measure? How does it relate to opportunity cost? Can you provide an example of how a change in opportunity cost could change the price elasticity of supply or demand in a market?
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to...
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to answer all parts! Do markets over-produce or under-produce negative externalities? Why? How could the government improve such market outcomes?
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to...
Answer the following questions with short paragraphs. Use economic reasoning to defend it. Make sure to answer all parts! How does the price elasticity of supply/demand relate to opportunity cost? Provide an example of how a change in opportunity cost could change the price elasticity of supply/demand in a market!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT