University | Nanyang Technological University (NTU) |
Subject | ST2195 Programming for data science |
Part 1
In this part, you are asked to work with the Markov Chain Monte Carlo algorithm, in particular the Metropolis-Hastings algorithm. The aim is to simulate random numbers for the distribution with the probability density function given below
Hire a Professional Essay & Assignment Writer for completing your Academic Assessments
Native Singapore Writers Team
- 100% Plagiarism-Free Essay
- Highest Satisfaction Rate
- Free Revision
- On-Time Delivery
where x takes values in the real line and |x| denotes the absolute value of x. More specifically, you are asked to generate x0, x1, . . . , xN values and store them using the following version of the Metropolis-Hastings algorithm (also known as random walk Metropolis) that consists of the steps below: Random walk Metropolis
Step 1 Set up an initial value x0 as well as a positive integer N and a positive real number s.
Step 2 Repeat the following procedure for i = 1, . . . , N:
• Simulate a random number x∗ from the Normal distribution with mean xi−1 and standard deviation s.
• Compute the ratio
• Generate a random number u from the uniform distribution between 0 and 1.
• If u < r (x∗, xi−1), set xi = x∗, else set xi = xi−1.
(a) Apply the random walk Metropolis algorithm using N = 10000 and s = 1. Use the generated samples (x1, . . . xN ) to construct a histogram and a kernel density plot in the same figure. Note that these provide estimates of f(x).Overlay a graph of f(x) on this figure to visualise the quality of these estimates. Also, report the sample mean and standard deviation of the generated samples (Note: these are also known as the Monte Carlo estimates of the mean and standard deviation respectively).
Practical tip: To avoid numerical errors, it is better to use the equivalent criterion log u < log r (x∗, xi−1) = log f (x∗) − log f (xi−1) instead of u < r (x∗, xi−1).
Stuck with a lot of homework assignments and feeling stressed ? Take professional academic assistance & Get 100% Plagiarism free papers
Excel in your NTU coursework with our expert support. From top-notch assignment writing service to dedicated Coursework Writing Services in Singapore, we assist you in projects like ST2195 Programming for Data Science. Pay for personalized guidance and navigate academic challenges with confidence, achieving excellence in your coursework.
Looking for Plagiarism free Answers for your college/ university Assignments.
- ECE210 Advocacy and Collaborations with Families Assignment: Supporting Young Children Through Grief and Family-Centered Partnerships
- ACC707 Accounting and Finance Assignment: Evaluating Investment Decisions, Budgeting Strategies, and Financial Performance Analysis
- NCO201 Learn to Learn, Learn for Life TMA-01: Developing Self-Directed Learning Through the Journey of Mastering Public Speaking
- PSS219 Public Safety and Security in Singapore Group-Based Assignment: Strengthening National Resilience Through Policy Responses from the 2025 Committee of Supply Debate
- MTH240 Engineering Mathematics I Assignment: Heat Transfer, Chemical Balancing, Circuit Analysis, Signal Processing, and Matrix Theory
- Engaging Youth with IBM Skills Build Assignment: Designing Innovative Strategies for Skill Development and Career Growth
- BUS368 Innovation Management and Digital Transformation Assignment: Managing Innovation in Foldable, Trifold, and Stretchable Display Technologies
- BUS366 Assignment: Process Improvement and Recruitment Optimization Using Lean Six Sigma Methodology
- HBC203 Statistics and Data Analysis for the Social and Behavioural Sciences TMA-01: A Comparative Analysis of Workplace Wellbeing Interventions and Their Impact on Employee Productivity
- BCAF003 Business Accounting Assignment: A Comprehensive Study on Bank Reconciliation, Cash Controls, Inventory Valuation, and Financial Analysis