\documentclass[11pt]{article}

\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}   % General awesomeness???
\usepackage{hyperref}
\usepackage{multirow}

\textwidth=6.5in
\textheight=9.0in
\oddsidemargin=0.0in
\evensidemargin=0.0in
\topmargin=0.0in
\headheight=0.0in
\headsep=0.0in
\parskip=0.0in
\parindent=0.0in

% Spacing commands
    \newcommand{\tab}{\hspace{0.5in}}
    \newcommand{\tib}{\hspace{0.1in}}
    \newcommand{\vib}{\vspace{0.15in}}


% Statistics function commands
    \newcommand{\prob}[1]{\operatorname{Pr} \left[ #1 \right]}
    \newcommand{\pdf}[2][]{f_{ #1 } \left( #2 \right)}
    \newcommand{\cdf}[2][]{F_{ #1 } \left( #2 \right)}
    \newcommand{\E}[2][]{\operatorname{E}_{ #1 } \! \left[ #2 \right]}
    \newcommand{\Var}[2][]{\operatorname{Var}_{ #1 } \! \left[ #2 \right]}
    \newcommand{\Cov}[2]{\operatorname{Cov} \left[ #1, #2 \right]}
    \newcommand{\info}[1]{\mathscr{I} \!\! \left( #1 \right)}

    \newcommand{\dBern}[1]{{\operatorname{Bern} \left( #1 \right)}}
    \newcommand{\dBeta}[2]{{\operatorname{Beta} \left( #1, #2 \right)}}
    \newcommand{\dBin}[2]{{\operatorname{Bin} \left( #1, #2 \right)}}
    \newcommand{\dCauchy}[1]{{\operatorname{Cauchy} \left( #1 \right)}}
    \newcommand{\dChiSq}[1]{{\chi^2 \left( #1 \right)}}
    \newcommand{\dDch}[3]{{\operatorname{Dirichlet} \left( #1, #2, #3 \right)}}
    \newcommand{\dExp}[1]{{\operatorname{Exp} \left( #1 \right)}}
    \newcommand{\dGamma}[2]{{\operatorname{Gamma} \left( #1, #2 \right)}}
    \newcommand{\dGeom}[2]{{\operatorname{Geom} \left( #1, #2 \right)}}
    \newcommand{\dMulti}[2]{{\operatorname{Mult} \left( #1, #2 \right)}}
    \newcommand{\dNegBin}[2]{{\operatorname{NegBin} \left( #1, #2 \right)}}
    \newcommand{\dNorm}[3][]{{\operatorname{N}_{ #1 } \! \left( #2, #3 \right)}}
    \newcommand{\dPois}[1]{{\operatorname{Pois} \left( #1 \right)}}
    \newcommand{\dUnif}[2]{{\operatorname{Uniform} \left( #1, #2 \right)}}
    \newcommand{\dWeib}[2]{{\operatorname{Weibull} \left( #1, #2 \right)}}


% Statistics symbol definitions and changes
    \newcommand{\iid}{\stackrel{\mathrm{iid}}{\sim}}
    \newcommand{\indep}{\perp\!\!\!\perp}
    \newcommand{\indepSim}{\stackrel{ind}{\sim}}
    \newcommand{\cLaw}{\stackrel{\mathscr{L}}{\longrightarrow}}
    \newcommand{\cProb}{\stackrel{\mathscr{P}}{\longrightarrow}}
    \newcommand{\cAS}{\stackrel{\mathrm{a.s.}}{\longrightarrow}}

    \renewcommand{\bar}{\overline}

% Mathematics symbol definitions and changes
    \newcommand{\rfrac}[2]{{}^{#1}\!/_{#2}}
    \newcommand{\kronecker}{\otimes}
    \newcommand{\tr}[1]{\operatorname{tr} \left( #1 \right)}
    \newcommand{\logit}[1]{\operatorname{logit} \left( #1 \right)}
    \newcommand{\logistic}[1]{\operatorname{logistic} \left( #1 \right)}
    \newcommand{\expit}[1]{\operatorname{expit} \left( #1 \right)}
    \newcommand{\Real}{\rm I\!R}
    \newcommand{\nin}{\not\in}

    \renewcommand{\d}{\partial}
    \renewcommand{\ln}{\ell n}
    \renewcommand{\approx}{\simeq}
    \newcommand{\appx}{\simeq}


% Greek alphabet changes
    \newcommand{\vep}{\epsilon}
    \newcommand{\vphi}{\varphi}
    \newcommand{\vtheta}{\vartheta}
    \renewcommand{\epsilon}{\varepsilon}

\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\labelenumii}{(\alph{enumii})}




\begin{document}

    \begin{center}
        {\Large \sc Stats 579 -- Intermediate Bayesian Modeling}\\
        \vspace{0.25in}
        {\Large Assignment \# 4}\\
    \end{center}

    \vspace{0.2in}

    \begin{enumerate}

        \item Suppose $y$ is a random variable with cdf $F(y) = 1 - e^{- \lambda y^{\alpha} }$ for $y > 0$, $\alpha > 0$. We say $y \sim \dWeib{\lambda}{\alpha}$. Explain how to simulate $y$ from $\dUnif{0}{1}$ random variables. Note that $y$ is a simple transformation of an $\dExp{\lambda}$ random variable. What is the transformation?

        \item If $Y_i \iid \dGamma{a_i}{b}$ for $i \in \{1,...,k\}$, we have shown that $$(Z_1, ..., Z_k) = \left( \frac{Y_1}{S}, ..., \frac{Y_k}{S} \right) \sim \dDch{a_1, ..., a_k},$$ where $S = \sum_{i=1}^k Y_i$. Use Proposition B.4 to transform $Y_1, ..., Y_k$ into the random vector $Z_1, ..., Z_{k-1}, S$. Show that $S$ is independent of the other variables by showing that the joint density of the random vector is the product of a $\dDch{a_1, ..., a_k}$ density and a $\dGamma{\sum_{i=1}^k a_i}{b}$ density. The general Dirichlet density is an obvious extension of the three-parameter Dirichlet density given in Table 2.1.

        \item In acceptance-rejection sampling, consider the general choice of candidate distribution for a log-concave target density as presented in class.

            Recall that we have $\tilde{\theta}_1$ and $\tilde{\theta}_2$, points on either side of the mode of $\ell(\theta) \equiv \log[ p_* (\theta) ]$; and that we have tangent lines to $\ell(\theta)$ calculated at these points, $$\gamma_i (\theta) = \ell(\tilde{\theta}_i) + \ell'(\tilde{\theta}_i) (\theta - \tilde{\theta}_i),$$ where $i \in \{1, 2\}$. Then $$p_*(\theta) = e^{\ell (\theta)} \leq e^{\gamma_i (\theta)}$$ for both $i=1$ and $i=2$. We choose $$Mq(\theta) = \min \left\{ e^{\gamma_1 (\theta)}, e^{\gamma_2 (\theta)} \right\}.$$

            \begin{itemize}
                \item[(a)] Find $\theta_*$ by setting $\gamma_1 (\theta_*) = \gamma_2 (\theta_*)$ and solving.\\
                \item[(b)] Integrate $Mq(\theta)$ over $(-\infty, \infty)$ to determine $M$ as a function of $\theta_*$, $\tilde{\theta}_1$, and $\tilde{\theta}_2$.
                \item[(c)] Obtain the cdf based on the density $q(\theta)$, say $$Q(v) \equiv \int_{-\infty}^{v} q(\theta) d\theta.$$ Do this first for $v \leq \theta_*$ and then for $v > \theta_*$. Calculate the latter as $\int_{-\infty}^{\theta_*} q(\theta) d\theta + \int_{\theta_*}^{v} q(\theta) d\theta$.
                \item[(d)] Solve $Q(v) = u$ for $v$ so that $v = Q^{-1}(u)$. Thus if we sample $U \sim \dUnif{0}{1}$, we have $Q^{-1}(U) \sim q(\cdot)$.
            \end{itemize}


        
    \end{enumerate}

\end{document} 