studio7_problem_1(0.7, 0.05, 18)
## ----------------------------------
## Problem 1: Rejection region, actual significance, power
## Rejection region: 13 14 15 16 17 18
## True significance= 0.04812622
## Power= 0.5343801
studio7_problem_2(0.7, 0.05, 18, 1000, c(0.3,0.7))
## ----------------------------------
## Problem 2: Simulation with a mixture of coins
## theta_HA=0.7, alpha=0.05
## n_tosses=18, n_trials=1000
## secret_prior= 0.3 0.7
## Number of rejections: 391
## Number of type 1: 5
## Number of type 2: 306
## P(rejection | H0): 0.01623377
## P(H0 | rejection): 0.01278772
## P(rejection | HA): 0.5578035
## P(HA | rejection): 0.9872123
## P(rejection): 0.391
studio7_problem_3a(0.7, 0.05, 18, 1000)
## -----
## 3a: Simulation with all fair coins: explain results
## ----
## ----------------------------------
## Problem 2: Simulation with a mixture of coins
## theta_HA=0.7, alpha=0.05
## n_tosses=18, n_trials=1000
## secret_prior= 1 0
##
## Giving the actual output from this function will give too much away. So we blank out the answers with ???
## Number of rejections: ???
## Number of type 1: ???
## Number of type 2: ???
## P(rejection | H0): ???
## P(H0 | rejection): ???
## P(rejection | HA): ???
## P(HA | rejection): ???
## # Problem 2 called from problem 3a----
## You need to edit the cat statements at the end of studio7_problem_3a() to give a short explanation of the estimated probabilities that go with the given prior.
studio7_problem_3b(0.7, 0.05, 18, 1000)
## -----
## 3b: Simulation with all ubfair coins: explain results
## ----
## ----------------------------------
## Problem 2: Simulation with a mixture of coins
## theta_HA=0.7, alpha=0.05
## n_tosses=18, n_trials=1000
## secret_prior= 0 1
##
## Giving the actual output from this function will give too much away. So we blank out the answers with ???
## Number of rejections: ???
## Number of type 1: ???
## Number of type 2: ???
## P(rejection | H0): ???
## P(H0 | rejection): ???
## P(rejection | HA): ???
## P(HA | rejection): ???
## # Problem 2 called from problem 3b----
## You need to edit the cat statements at the end of studio7_problem_3b() to give a short explanation of the estimated probabilities that go with the given prior.
studio7_problem_3c()
## -----
## 3c: Explain difference between P(H0 | rejection) and significance
## You need to edit the cat statements at the end of studio7_problem_3c() to explain the difference asked about.
studio7_problem_3d()
## -----
## 3d: Shout it out!
## You need to edit the cat statements at the end of studio7_problem_3d() to shout and say what is asked.
studio7_problem_4(0.7, 0.05, 18, c(0.1, 0.9))
## ----------------------------------
## OPTIONAL 4: Use Bayes theorem
## true P(H0 | rejection): 0.009907515
## true P(HA | rejection): 0.9900925
# Compare the problem 4 results with the simulated results in problem 2.
studio7_problem_2(0.7, 0.05, 18, 10000, c(0.1, 0.9))
## ----------------------------------
## Problem 2: Simulation with a mixture of coins
## theta_HA=0.7, alpha=0.05
## n_tosses=18, n_trials=10000
## secret_prior= 0.1 0.9
## Number of rejections: 4918
## Number of type 1: 54
## Number of type 2: 4181
## P(rejection | H0): 0.0565445
## P(H0 | rejection): 0.01098007
## P(rejection | HA): 0.5377557
## P(HA | rejection): 0.9890199
## P(rejection): 0.4918
18.05 Introduction to Probability and Statistics
Spring 2022
Authors: Jeremy Orloff and Jennifer French
For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms