No tutorial next week due to lunar new year holiday.
New TA and our division of works
Rules for seeking help
Solution of assignment 1 will be posted next week. I recommend reading the comment questions (Ex1.2.5 and Ex1.3.3) as the messages are quite interesting.
If I omit a question, that usually means the hints are sufficient so you can just refer to the Remark in the assignment.
This question is open-ended. However, I would like to remind you that you cannot use information from last semester’s STAT/RMSC courses. Otherwise, you might use the data twice. Some possible data sources are:
From 2.2.1, you have obtained the form of \[ f(\theta \mid y_{1:n}) \propto f(y_{1:n} \mid \theta) f(\theta). \] To derive the posterior under re-parametrization quickly, you may use the fact that \(f(y_{1:n} \mid \phi) \equiv f(y_{1:n} \mid \theta)\) when \(\phi\) and \(\theta\) have one-to-one relationship.
Deriving the required posterior is quite tedious. Try to factor out \(\exp( -\beta_n/\sigma^2)\) first and simplify the remaining terms to compare with Remark 2.3.2.
There are two difficulties in this question. First, we cannot directly compute, e.g., \(\Gamma(799)/2^{6550}\) in R:
gamma(799) /2^6550
## [1] NaN
To compute this ratio, we can write:
exp(lgamma(799) -6550*log(2))
## [1] 0.2162598
Since \[ \frac{\Gamma(799)}{2^{6550}} = \exp \left\{ \log \left( \frac{\Gamma(799)}{2^{6550}} \right) \right\} = \exp \left\{ \log\Gamma(799) - 6550\log 2 \right\}, \] we can “transform” the problem to computing smaller numbers. Similar problems appear in machine learning as well. For example, the standard logistic function can be defined as either \[ w(t) = \frac{e^t}{e^t+1} \quad \textrm{or} \quad w(t) = \frac{1}{1+e^{-t}}. \] When \(t\) is large, observe that
t = 1e5
exp(t)/(exp(t)-1)
## [1] NaN
1/(1+exp(-t))
## [1] 1
Therefore, the formula used for computation can make a difference.
Second, the question requires the function to return a vector. In other words, the function should compute \(f(\theta \mid x_{1:n})\) for each value in the argument \(\theta\).