Question: DONT USE POINTERS OR VECTORS x y 0 4.835 0.04 4.92 0.1 5.143 0.12 5.227 0.22 5.591 0.24 5.638 0.26 5.704 0.32 5.906 0.34 6.023
Goals: Developing problem-solving skills, declaring variables, reading data from a file, using loops, and using arrays and functions. Problem: Many engineering and scientific relationships can be manipulated to a format of a straight line, y- mx +b, where m is the slope of the line and b is the y intercept. However, because most measurements have some inherent error, the formula for the line may not be obvious. Therefore, linear regression may be used to determine the best fit of a line to the measured data. Linear regression uses the following two equations for calculations of slope and y-intercept. Slope- 2y-nx y) (2x) -n2(x) 2y -slope Ex y-intercept- where n is the number of (x,y) data sets that were measured. The "goodness of fit" of this straight line can be estimated by summing the square of the residuals. The residual is defined as the difference between the measured y value and the calculated y value (using the calculated slope and y-intercept) for a given x. The equation is shown below where ym is the measured goodness of fit"-Zym-y)2 y value and yc is the calculated y value. A lower"goodness of fit" value indicates a better match of the line to the data. For this assignment you write the C++ source code that uses a set of data to determine the slope and y-intercept of the line the best fits this data. The data is stored in a file called
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
