首页 >
> 详细

CSCI 739.02 - Human Behavior Modeling Homework 2 October 8, 2019

Homework 2: Making Inferences from the Posterior Distribution

Solutions to this assignment are to be submitted in myCourses via Assignment (formerly

known as Dropbox). The submission deadline is Wednesday October 16, 2019 at

11:59pm. You should submit a zipped file containing a pdf (this could be a scanned

handwritten document or a latex/Word generated pdf) with your written answers and the

Jupyter notebook with any code needed for the assignment. Use comments to explain your

code. All code and plots should be in the notebook while

descriptions/explanations/derivations should be in the PDF.

Question: Inferring the posterior for a Gaussian likelihood example [PDF] The goal of this

assignment is to review Module 2 in class where we discussed different techniques for deriving the

parameters of the posterior distribution. We reviewed the direct estimation of parameters using conjugate

priors, point estimations (MAP and MLE) of the posterior, and lastly, simulating and testing parameters

in order to eventually generate samples directly (Metropolis-Hastings Sampling a form of Markov Chain

Monte Carlo - MCMC). Statistics of the samples can then be calculated.

If x1, x2, . . . , xn are independent observations of a random variable x in a dataset of size n, then the

likelihood for the model (or the joint probability of all x0is) is:

f(X|θ) = Yni=1f(Xi|θ)

Because the Gaussian distribution is used quite a bit in behavior modeling, we will dive into working

with the Gaussian likelihood function in the following exercises:

(a) (20 points) Derive the form of the posterior distribution if the likelihood is a Gaussian with known

variance σ2, but unknown mean µ, where the conjugate prior is also of the Gaussian form. This

is a contrived example since we generally do not know σ2, but it keeps the mathematics simpler,while still making the concepts clear. Use f(µ|X) ∝ f(X|µ)f(µ)What can you say about the relationship between the parameters of the posterior, prior and likelihood

functions?

(b) (30 points) For the example described above, derive the expressions for the maximum likelihood

θMLE and maximum a posteriori θMAP

(c) (35 points) Suppose we have a class of 30 students who are about to take an exam, their heart rates

(HR) are measured and the mean HR is ¯x = 75, with a standard deviation σ = 10 (in line with the

derivations above, variance is known). Heart rate can give a measure of how stressed the students

are going in to an exam. But having taken similar measurements before, over different semester

exams, the past HR means have given us an overall mean µ of 70. The past means have varied from

semester to semester giving us a standard deviation of the means of τ = 5, i.e. τ reflects how much

our past means have varied but does not really reflect the variability of the individual heart rates.

You goal is ultimately to update the knowledge of µ in f(µ|x). Using the expressions obtained

above, find the value of θMAP. Be careful when substituting the different values of means and

variances/std dev in your formula.

Which function has more influence on the posterior in this problem? The prior or the likelihood?

Why do you conclude this?

(d) (15 points) Using the Metropolis-Hastings algorithm, write your own sampler to simulate points

from the posterior. The steps to accomplish this are:

1. Establish the starting value for parameter θ

j=0; set the counter j=1

2. Draw a “candidate” parameter (or proposal) θc

from a proposal distribution (usually another

Gaussian)

3. Compute the ratio ρ = min(1,f(θc)f(X|θc)f(θj−1)f(X|θj−1))

4. Compare ρ with a random draw u from U(0, 1). If ρ > u, then accept the proposal by setting; Record the number of accepted proposals. Efficiency of the

algorithm will be computed as #num accepts

#num iterations

5. Set j = j + 1 and return to step 2 until enough draws are obtained

You are provided with a Jupyter notebook Sampling.ipynb that was written for a binomial

likelihood and beta prior. Modify this sample code to (i) write your MCMC sampler for the

problem described in part (c) and (ii) plot the true posterior, the distribution of your simulated

samples as well as the distribution of prior samples, all on the same figure. Note that your

likelihood is a Gaussian with known variance and there is a lot more code here than is required

for your homework.

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp2

- 代写artificial课程作业、Java，Python程序语言作业调试、C 2020-05-27
- Comp Sci 3306作业代写、Python编程语言作业调试、代做jav 2020-05-27
- Data留学生作业代写、代做r课程设计作业、Analytics作业代做、R编 2020-05-27
- Csci 3120作业代做、C++程序语言作业调试、代做c/C++课程作业、 2020-05-26
- 代写algorithms作业、Data留学生作业代做、代写java、Pyth 2020-05-26
- Data Science作业代写、C++程序设计作业代写、Programmi 2020-05-26
- Data课程作业代写、C++编程设计作业调试、C/C++语言作业代做、Alg 2020-05-26
- 代写r留学生作业、代做data课程作业、代写r编程语言作业代做r语言编程|调 2020-05-25
- Cosc473作业代做、Systems作业代写、Python编程设计作业调试 2020-05-25
- Data留学生作业代做、R编程设计作业调试、R语言作业代写、Program课 2020-05-25
- Comp 250 Assignment 3 2020-05-24
- Macm 316 – Computing Assignment 7 2020-05-24
- Sta457 Assignment 2020-05-24
- Homework 10 2020-05-24
- Lab 2 Msc: Time Series Prediction With... 2020-05-24
- Comp2011作业代做、Data Analysis作业代写、C++编程语言 2020-05-24
- 代做compsys201作业、Python，Java，C/C++编程语言作业 2020-05-24
- Program留学生作业代做、Python编程设计作业调试、Data作业代写 2020-05-24
- 代写 Practical 3 Covid-19程序作业，代写... 2020-05-23
- 代写comp3059作业、代做programming作业、Java语言作业代 2020-05-23