number 1 continues on page 2 part 1 continued and part 2 i need help writing the
ID: 3802417 • Letter: N
Question
number 1 continues on page 2part 1 continued and part 2
i need help writing these programs i'm so lost Engr 1732 Lab8 Regression Data Analysis and two Dimensioned Arrays 1) write a cyc. program that does first order linear regression analysis on the three laboratory data sets listed below. Note your program should print out a separate table of calculated results for each original (X,Y) data set the new values of Y calculated for original values of x using the newly determined slope and yintercept. Each of the 3 printed out tables should list the original (xY)data and the new curve fitted data denoted by Y new Note the original values do not change, only the Y values Log freq Gain Temp "C Diode Cap volts Energy (ul) 1 al 20 720 2556 010 1015 24 29 3.16 0.37 495 255 128 3.334 0,514 497 35 683 57 79 64.2 40 674 46 62 i 32 45 666 668 50 657 3,556 0707 i 149 212 636 156 097 R202 398 65 624 43 34 0985 70 616 446 75 603 4756 100 80 1592 185 578 566 553 Use the following formulas for sums S1 S2,S3 and SA The x,Y data set should be entered by typing in each xin and Yuvalue using a for loop with cin»xt] and cin Ylij. After data is entered, use formulas below inside a for loop: For (int i 0; ikaN-1;
Explanation / Answer
Here I am Providing Answer for Part1 only.
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
int x[],y[],ynew[],s1,s2,s3,s4,xmean,ymean,A,B,N;
clrscr():
for(int i=0;i<=N-1;i++){
cout<<"x["<<i<<"]= ";
cin>>x[i];
cout<<"y["<<i<<"]= ";
cin>>y[i];
}
for(int i=0;i<=N-1;i++)
{
s1=s1+x[i]*y[i];
s2=s2+x[i];
s3=s3+y[i];
s4=s4+x[i]*x[i];
}
xmean=s2/N;
ymean=s3/N;
B=(s1-((s2*s3)/N))/(s4-((s2*s2)/N));
A=ymean-(B*xmean);
for(int i=0;i<=N-1;i++){
ynew[i]=B*x[i]+A;
}
cout<<"Coefficient A="<<A;
cout<<"Coefficient B="<<B;
cout<<"The X value and new Y values are: "
for(int i=0;i<=N-1;i++)
{
cout<<"x["<<i<<"]= "<<x[i]<<" y_new["<<i<<"]= "<<ynew[i]<<endl;
}
Hence the solution provided.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.