Question: Please answer program 2 in C Program 2 - Linear Regression A more powerful technique for estimating linear data is called linear regression. The simplest

Please answer program 2 in C

Please answer program 2 in C Program 2 - Linear Regression Amore powerful technique for estimating linear data is called linear regression. Thesimplest form is linear regression for two variables, a model in whichone variable is expressed as a linear function of the other. Let'suse the same data set we used in the linear interpolation problem

Program 2 - Linear Regression A more powerful technique for estimating linear data is called linear regression. The simplest form is linear regression for two variables, a model in which one variable is expressed as a linear function of the other. Let's use the same data set we used in the linear interpolation problem above, but this time we'll find the best line fit through those points using linear regression. 14 12 10 10 12 14 16 18 t (seconds) Here we have the same data set as we used before, but we are now fitting a straight line through those points instead of interpolating between adjacent points Of course, a straight line is given by the equation y=b+ vt where, in this case, y represents the meters traveled (vertical axis) and t represents the time value (horizontal axis). Note that the only unknowns in this equation are b, the x intercept, and v, the slope of the line. These are called the regression coefficients and may be calculated with the following formulae: 2-1 where n represents the number of data points, yu represents the mean value of the positions (meters) and represents the mean value for the times. This is common method of calculating the intercept and slope of a line is called the least squares method Write a C program that calculates the regression coefficients for the above data set and reports them to the user. In addition, determine the position value (y) for time seconds using your regression coefficients and report that well y - XX.XX at time 11 seconds Introduction Your fifth assignment will consist of two small C programs. The C programs should be submitted as a standard C source code file. Please note that your computer programs should comply with the commenting and formatting rules as described in class. For example, there should be a header for the whole program that gives the author's name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions Program 1 - Linear Interpolation The technique of interpolation can be used for estimating values between data points. The simplest method of interpolation is called linear interpolation, shown in the following figure. In this case, two adjacent points are connected with a straight line (+1Y+1 (Ki y): Figure 4.5 Linear interpolation The value of y for any x between two adjacent points (xi, yi) and (Xi+l, yi+ following equation is given by the y= yi + Xi+i-Xi In a lincar interpolation, a straight line first-order polynomial is used to connect two adjacent points. For a smoother interpolation, a second or third-order polynomial (or even cubic splines) can be used to interpolate values between every two points. Thesc latter techniques are outside the scope of this assignment. For purposes of this assignment, let's initialize our data set to contain the following points (Later we may modify this program to read data points from an input file.) Note that the point (y.t) represents the position of an object in meters at time t Table 4.3 Time and position for a moving body t (seconds) 10 12 15 18 y (meters) 2 5.2 6 1010.4 13.414.8 18 Viewing these data in a graphical format 18 16 14 12 8 6 4 0 2 46 8 10 12 14 16 18 t (seconds) Figure 4.6 Position versus time for a moving body with data in Table 4.3 You can store the time and distance values in two separate parallel arrays or in an array of structures Your program should do the followin 1. Initialize time and distance arrays to the above values using initialization lists 2. Ask the user for some number of seconds between 0 and 18 inclusive. a. This should be a floating point data type, either float or double b. If the user inputs a value outside that range, your program should print an error message and give the user the chance to enter another number 3. Determine where on the time scale the inputted number resides For example, if the user inputs the number 11, that resides between the time values of 10 and 12 a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!