Write a program in (mathrm{R}) that simulates a sequence of independent and identically distributed random variables (B_{1},
Question:
Write a program in \(\mathrm{R}\) that simulates a sequence of independent and identically distributed random variables \(B_{1}, \ldots, B_{500}\) where \(B_{n}\) is a \(\operatorname{BERNOuLLi}(\theta)\) random variable where \(\theta\) is specified below. For each \(n=3, \ldots, 500\), compute
\[n^{1 / 2}\{\log [\log (n)]\}^{-1 / 2}\left(\bar{B}_{n}-\thetaight),\]
where \(\bar{B}_{n}\) is the sample mean computed on \(B_{1}, \ldots, B_{n}\). Repeat the experiment five times and plot each sequence
\[\left\{n^{1 / 2}\{\log [\log (n)]\}^{-1 / 2}\left(\bar{B}_{n}-\thetaight)ight\}_{n=3}^{500}\]
against \(n\) on the same set of axes. Describe the behavior observed for the sequence in each case in terms of the result of Example 5.3. Repeat the experiment for each \(\theta \in\{0.01,0.10,0.50,0.75\}\).
Step by Step Answer: