- Generate the training set:
- 𝑁𝑁𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 = 10
- 𝑋𝑋𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 contains samples from a uniform distribution U(0,1).
- 𝑡𝑡𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 = sin2𝜋𝜋𝑋𝑋𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 + 𝜀𝜀, where 𝜀𝜀 is drawn from a Gaussian (Normal) distribution N(0, 𝜎𝜎 =0.3).
- Generate the test set:
- 𝑁𝑁𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 = 100
- 𝑋𝑋𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 contains samples from a uniform distribution U(0,1).
- 𝑡𝑡𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 = sin(2𝜋𝜋𝑋𝑋𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇) + 𝜀𝜀, where 𝜀𝜀 is drawn from a Gaussian distribution N(0, 𝜎𝜎 =0.3).
- Use the method of linear regression with non-linear models to fit polynomials of degree 𝑀𝑀 = 0,1,2, … ,9 to the training set.
- Record the training and testing errors for each of the 10 cases.
- Produce the plot as shown below, where
𝐸𝐸𝑅𝑅𝑅𝑅𝑅𝑅 = 𝐽𝐽𝑤𝑤/𝑁𝑁
- Repeat the exercise for 𝑁𝑁𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 = 100.
Upload your .m or .py file to Blackboard prior to the deadline.



