Question: Write a code in MATLAB complete all the parts for this question step by step as suggested In this problem, we will modify the GradDescentEx1.m


Write a code in MATLAB complete all the parts for this question step by step as suggested
In this problem, we will modify the GradDescentEx1.m file from the canvas code to illustrate gradient descent. Because this matrix is only 2x2, we can plot the progress of each step of x in 2 dimensions by plotting (1) against (2). (a) Starting with the GradDescentEx1.m file, replace the A matrix and b vector so that they are generated by random integers between 1 and 1000 and change each time you run the program. (c) Inside the while loop, record the values of x for each iteration. (d) After iterations are complete, plot the values of x for each iteration, using '--o'. (e) Now calculate the true value of x using x=Ab. (f) Change the final print statement to include the true values and plot the true value of x in a different color from the gradient descent. (e) Run this program a few times. Does the algorithm always converge on the correct x solution? Do you notice any similarities in the plots when it does not converge? (Include some example plots in your report..if you are using .MLX for your report, you can insert images by clicking on the insert tab above). (f) The value alpha determines the size of the step that the algorithm takes. In machine learning, this alpha is called the "learning rate parameter". Investigate the impact of different values for alpha by commenting out the alpha line in the while loop trying some different values for alpha between 0.0001 and 1.0 . What happens when alpha is too small? What happens when alpha is too large? What does the alpha formula that you commented out do differently than a constant value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
