1. Let \(X_1, \ldots, X_N \sim \text{Poisson}(\lambda = 1.84)\). The probability density function for the Poisson random variable is \[ f(x | \lambda) = \lambda^x e^{{-\lambda}} / x! \] for \(x \in 0, 1, 2, 3, \ldots\) and \(\lambda > 0\)

    1. By hand, calculate the simplified log-likelihood and then write the simplified log-likelihood as a Python function with signature \(\texttt{ll_poisson(l, x)}\).

    2. By hand, calculate the maximum likelihood estimator. Include a photo of your hand written solution, or type out your solution using LaTeX.

    3. Create an array \(\texttt{X}\) by generating \(N = 1001\) Poisson random variables, with \(\lambda = 1.84\) from above. Use \(\texttt{np.random.poisson(}\lambda \texttt{, N)}\).

    4. Use \(\texttt{scipy.optimize.minimize(ll, (l0), args=(X), method='L-BFGS-B', bounds=[...])}\) to calculate the maximum likelihood estimate \(\hat{\lambda}\) of \(\lambda\).

  2. Let \(X_1, \ldots, X_N \sim \text{IG}(\mu = 12.41, \lambda = 3.9)\), named inverse Gaussian or Wald. The probability density function for the inverse Gaussian random variable is \[ f(x | \mu, \lambda) = \left( \frac{{\lambda}}{{2\pi x^3}} \right)^{1/2} e^{{ -\frac{{\lambda(x - \mu)^2}}{{2\mu^2x}} }} \] for \(x > 0\), \(\mu > 0\), and \(\lambda > 0\).

    1. By hand, calculate the simplified log-likelihood and then write the simplified log-likelihood as a Python function with signature \(\texttt{ll_ig(theta, x)}\).

    2. Create an array \(\texttt{X}\) by generating \(N = 1001\) IG/Wald random variables, with \(\mu = 12.41\), \(\lambda = 3.9\) from above. Use \(\texttt{np.random.wald(}\mu, \lambda \texttt{, N)}\).

    3. Use \(\texttt{scipy.optimize.minimize(ll, theta0, args=(X), method='L-BFGS-B', bounds=[...])}\) to calculate the maximum likelihood estimate \(\hat{\theta}\) of \(\theta = (\mu, \lambda)\).