Header
Header
Student Name: Chiara Tombolini Assignment: Week 9 - Monte Carlo OLS & Numerical Integration
Overall Assessment
Grade: ⚠️ (Partial)
The submission has several issues preventing successful execution and correct results. First, the file structure is invalid (function defined at the top of a script). Second, the Simpson’s rule implementation detects even grids (which all required N values are) but then sets the result to NaN instead of adjusting the grid to calculate a value. This contradicts your comments stating that Simpson’s rule was “more accurate,” as your code actually produced no results for it.
Task-by-Task Check
- Function Definition: ⚠️ Structure Error. The function is at the top of the file. It must be at the end.
- DGP Logic: ✅ Correct.
- OLS Logic: ⚠️ Logic Error. You calculate
meanandvarofbeta1_hat(lines 22-23) before the loop that fills it. This results in 0 values being printed initially. - Execution: ⚠️ Script flow is broken by structure.
- Visuals: ✅ Code for histograms present.
- Statistics: ❌ Computed on empty vector initially.
- Interpretation: ✅ Text present.
- Utility Function: ✅ Correct.
- Trapezoidal Rule: ✅ Correct.
- Simpson’s Rule: ❌ Incorrect. You correctly identify that N is even, but instead of fixing it (e.g., by using
N-1points), you outputNaN. Since N=50, 200, 1000 are all even, you get no Simpson results. - Grid Loop: ✅ Correct.
- Visuals: ✅ Code present.
- Interpretation: ❌ Your comments claim Simpson is more accurate, but your code produced
NaNfor all cases. This suggests the interpretation was written without checking the results.
Technical Implementation
- Structure: Invalid MATLAB file structure.
- Logic: Printing stats of an empty vector.
- Simpson: Returning NaN instead of handling the grid.
Suggestions for Improvement
- Move Function: Place
montecarlo_olsat the end of the file. - Fix Stats: Calculate mean/var after the loop in the function (or in the main script).
- Fix Simpson: If
mod(N,2)==0, usec(1:end-1)anduc(1:end-1)to perform the calculation, rather than returningNaN.
Summary
5/13 tasks correct. Significant structural and logical errors need addressing.