An ancient pirate coin spent centuries in a treasure chest at the bottom of the sea, and is now a bit gnarly and unbalanced. Can it nevertheless be considered to be a fair coin? To test the idea, students flipped the pirate coin 140 times and it came up heads 83 times.

`library(tidyverse)`

Compare the pirate coin to a fair coin which has probability \(\pi = 0.5\) of success.

This is a two-sided test because the pirate coin might come up heads too frequently or too infrequently.

\[H_0 : \pi = 0.5\] \[H_0 : \pi \not= 0.5\]

State \(\pi\) and \(\alpha\)

```
pi <- 0.5
alpha <- 0.05
```

```
x <- 83 # observed successes
n <- 140 # sample size
(p.hat.observed <- x / n)
```

`## [1] 0.5928571`

```
coin <- data.frame(response = c("head", "tail"),
p = c(p.hat.observed, 1 - p.hat.observed))
str(coin)
```

```
## 'data.frame': 2 obs. of 2 variables:
## $ response: Factor w/ 2 levels "head","tail": 1 2
## $ p : num 0.593 0.407
```

```
ggplot(coin, aes(response, p, fill = response)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = c("bisque", "burlywood")) +
labs(title = "Scissors")
```