Write a function to perform a least squares fit of N data points to a straight line using the following steps ### Steps1. Create sample data set and visualize test data. An example using the...

1 answer below »
Write a function to perform a least squares fit of N data points to a straight line using the following steps
### Steps1. Create sample data set and visualize test data. An example using the make_regression function in the sklearn library is provided below. For full credit you must write your function to generate a noise sample data set. Your function should take as input * The desired number of data points (x,y) * The slope $a$ and intersept $b$ of your data $y =ax+b$ * A parameter to choose a noise level for the y's.1. Implement your own least squares fit function using the derivation in the provided notebook.. Your function must return at the minimum the predicted parameters for slope and intersept and the value of $\chi^2$.1. Create a figure of your data and your fitted line.1. Perform a linear regression off the same data set using a linear regression function from a scientific library of your choice (scipy, numpy, sklearn). One choice is **numpy.linalg.lstsq** but it is certainly not the easiest to use. Use the online documentation (https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.lstsq.html) to understand how it works.1. Verify that your result and the library routine agree.

Answered 4 days AfterDec 05, 2021

Answer To: Write a function to perform a least squares fit of N data points to a straight line using the...

Subhanbasha answered on Dec 10 2021
123 Votes
Report
Question1:
    Here we have created the function for generating the sample data with the requi
red format. The inputs will be the number of sample we need to generate for our sample data and noise need to be present in the data. The make_regression() function very useful to generate the data where the data will be the best fit for the regression. It will take many parameters we can generate number of columns as we want by specifying the value then it will generate data required predictors and the response variable.
There we have given the required parameters by entering user input it will generate data for predictor that is x and response variable y so that the values will be used in the further step of creating regression.
Question 2:
    The lease square method is very popular method in the regression analysis where it will reduce the error of the...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here