STAT 450: Midterm coding portion

library(tidyverse)
library(purrrfect)

Question 1

An urn has ten 6-sided dice. Seven of the dice are fair (numbered 1-6) and three have sixes on all 6 sides. A single die is drawn at random and rolled.

Write a function one_omega() and use purrrfect::replicate() to simulate 10,000 replications of this experiment. Use your simulated experiments to estimate the probability that the die drawn was fair if a 6 was rolled.

Question 2

Suppose \(X \sim GAM(\alpha, 1)\) and \(Y \sim GAM(\beta, 1)\). It can be shown that \(U = \frac{X}{X+Y} \sim BETA(\alpha,\beta)\). Use a simulation study to verify this by simulating 10,000 realizations of \(U\) when defined this way for each combination of \(\alpha \in \{1,2,4\}\) and \(\beta \in \{1,2,4\}\). Plot the simulated densities overlaid with their analytic densities.