Objective #1: Implement a function in Matlab that finds that parameters, b_hat, of a polynomial regression model. Begin from 'regress_fit_poly.m', which is a stub (i.e., unfinished) version of the function provided for you. The inputs and outputs of your function should conform to the following specifications: % Inputs: % x - A n-by-1 vector of feature values % (where n is number of data points) % y - A n-by-1 vector of response variable values % p - A scalar value, indicating the polynomial order % Outputs: % b_hat - a p+1-by-1 vector of regression coefficients Note: Your function should be able to calculate the polynomial regression parameters for a model of any order (i.e., an input ‘p’ of any value). Note: To see if your function is working correctly, you can check the outputs of your function against those produced by Matlab's 'polyfit' function. However, you should not call ‘polyfit’ inside your own function. Note: Pay special attention to the order of the parameters, which is important, and which may be different than you expect. If you notice that the parameters coming from your function differ from those of 'polyfit', think hard about how you might rearrange them to match. You have several options. For instance, you could change the ordering of columns in the design matrix. Alternatively, you could look into the Matlab functions 'fliplr' and 'flipud', which might help.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Objective #1:
Implement a function in Matlab that finds that parameters, b_hat, of a polynomial regression model.
Begin from 'regress_fit_poly.m', which is a stub (i.e., unfinished) version of the function provided for
you. The inputs and outputs of your function should conform to the following specifications:


% Inputs:
% x - A n-by-1 vector of feature values
% (where n is number of data points)
% y - A n-by-1 vector of response variable values
% p - A scalar value, indicating the polynomial order

% Outputs:
% b_hat - a p+1-by-1 vector of regression coefficients


Note: Your function should be able to calculate the polynomial regression parameters for a model of any
order (i.e., an input ‘p’ of any value).


Note: To see if your function is working correctly, you can check the outputs of your function against
those produced by Matlab's 'polyfit' function. However, you should not call ‘polyfit’ inside your own
function.


Note: Pay special attention to the order of the parameters, which is important, and which may be different
than you expect. If you notice that the parameters coming from your function differ from those of 'polyfit',
think hard about how you might rearrange them to match. You have several options. For instance, you
could change the ordering of columns in the design matrix. Alternatively, you could look into the Matlab
functions 'fliplr' and 'flipud', which might help.

 
### Polynomial Regression Function Documentation

#### Function Definition
```matlab
function b_hat = regress_fit_poly(x, y, p)
```

#### Purpose
The `regress_fit_poly` function computes the coefficients of a polynomial regression model given input vectors `x` and `y`, and the polynomial order `p`.

#### Inputs
- **x**: A n-by-1 vector containing feature values, where `n` denotes the number of data points.
- **y**: A n-by-1 vector containing response variable values.
- **p**: A scalar indicating the order of the polynomial.

#### Outputs
- **b_hat**: A (p+1)-by-1 vector of regression coefficients.

#### Metadata
- **Created by**: Adam C. Lammert (2020)
- **Author**: ??? (Insert your name)

#### Description
This function, `regress_fit_poly`, is designed to calculate the coefficients necessary for fitting a polynomial regression model to the provided data. The calculation is based on the feature values (`x`), the corresponding response values (`y`), and the specified polynomial order (`p`).

```matlab
% Example code snippet
% <your code goes here – several lines will be required>

return
%end of file
```

In the above script, you need to replace the placeholder `your code goes here – several lines will be required` with the actual implementation of the polynomial regression fitting.

### Note
Ensure to write efficient and clean code for the polynomial fitting and document your approach well in the script.
Transcribed Image Text:### Polynomial Regression Function Documentation #### Function Definition ```matlab function b_hat = regress_fit_poly(x, y, p) ``` #### Purpose The `regress_fit_poly` function computes the coefficients of a polynomial regression model given input vectors `x` and `y`, and the polynomial order `p`. #### Inputs - **x**: A n-by-1 vector containing feature values, where `n` denotes the number of data points. - **y**: A n-by-1 vector containing response variable values. - **p**: A scalar indicating the order of the polynomial. #### Outputs - **b_hat**: A (p+1)-by-1 vector of regression coefficients. #### Metadata - **Created by**: Adam C. Lammert (2020) - **Author**: ??? (Insert your name) #### Description This function, `regress_fit_poly`, is designed to calculate the coefficients necessary for fitting a polynomial regression model to the provided data. The calculation is based on the feature values (`x`), the corresponding response values (`y`), and the specified polynomial order (`p`). ```matlab % Example code snippet % <your code goes here – several lines will be required> return %end of file ``` In the above script, you need to replace the placeholder `your code goes here – several lines will be required` with the actual implementation of the polynomial regression fitting. ### Note Ensure to write efficient and clean code for the polynomial fitting and document your approach well in the script.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Temporal Difference Learning
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education