faces

reference:
- Tintle, et al., ISI, exploration 1.3, p. 50

hypotheses

Define \(\pi\).

SOLUTION:

\[H_0 : \pi = 0.50\] \[H_a : \pi > 0.50\]

Assign values to \(\pi\) and \(\alpha\).

pi <- 0.50          # probability of success
alpha <- 0.05       # level of significance

simulation

Design an experiment: “success” means that “Tim” was chosen as the name of the person in the photo on the left (with all the dark hair)… “success” often stands for the event being studied, even if that doesn’t sound very “successful” … choose “success” with probabiity 0.50 … repeat 24 times (\(n = 24\) students in a Stat 204 class)

n <- 24
faces24 <- function(){
  sample(0:1, size = n, replace = TRUE)   # flip a "fair" coin
}
faces24()
##  [1] 0 0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 0 0 1 1 1 1

Modify the experiment: choose “success” with probabiity 0.50 … repeat 24 times … report the proportion of successes.

faces24 <- function(){
  samp <- sample(0:1, size = n, replace = TRUE)   # flip a "fair" coin
  p.hat <- mean(samp)
  return(p.hat)
}

Repeat the experiment 10 times.

replicate(10, faces24())
##  [1] 0.5000000 0.5833333 0.3750000 0.5416667 0.5833333 0.7083333 0.4166667
##  [8] 0.4583333 0.5000000 0.4583333

sampling distribution of \(\widehat{p}\)

Repeat the experiment 1000 times and display the results.

n.experiments <- 1000
df <- data.frame(p.hat = replicate(n.experiments, faces24()))
str(df)
## 'data.frame':    1000 obs. of  1 variable:
##  $ p.hat: num  0.333 0.292 0.5 0.5 0.292 ...
draw.sampling.distribution(df)