Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C program: For this problem you will make modifications and extensions t

ID: 3668098 • Letter: W

Question

Write a C program:

For this problem you will make modifications and extensions to the least squares linear regression progra m discussed in class on February1. The source code, regression.c, is available in the Class Examples folder in the Resources section of the connex site. Background The linear correlation coefficient (denoted r), measures the strength and the direction of a linear relationship between two variables. The linear correlation coefficient is sometimes referred to as the Pearson product moment correlation coefficient in honour of its developer Karl Pearson. It is computed as follows: The value of r is such that -1 +1. The and signs are used for positive linear correlations and negative linear correlations, respectively. Positive correlation Ifxand y have a strong positive linear correlation, r is close to +1. An r value of exactly +1 indicates a perfect positive fit. Positive values indicate a relationship betwee x and y variables such that as values n for xincreases, values for y also increase. Negative correlation: Ifxand y have a strong negative linear correlation, ris close to -1. An rvalue of exactly -1 indicates a perfect negative fit. Negative values indicate a relationship between x and y such that as values for x increase, values for y decrease. No correlation If there is no linear correlation or a weak near correlation, r is close to 0. A value near zero means that there is a random, nonlinear relationship between the two variables Note that ris a dimensionless quantity that is, it does not depend on the units employed A perfect correlation of t 1 occurs only when the data points a e exactly on a straight line. If r 3-1, the slope of this line is positive. If r 1, the slope of this line is negative. A correlation reater than 0.8 is gene described as strong, whereas a correlation less than 0.5 is ra enera described as weak. These values can vary based upon the "type of data being examined.

Explanation / Answer

Can help you with this:

#include<stdio.h>
#include<math.h>
int main()
{
float r,xx[5],xy[5],yy[5],nr=0,dr_1=0,dr_2=0,dr_3=0,dr=0;
float x[5]={60,61,62,63,65},y[5]={3.1,3.6,3.8,4.0,4.1};
float sum_y=0,sum_yy=0,sum_xy=0,sum_x=0,sum_xx=0;
int i,n=5;
for(i=0;i<n;i++)
{
xx[i]=x[i]*x[i];
yy[i]=y[i]*y[i];
}
for(i=0;i<n;i++)
{
sum_x+=x[i];
sum_y+=y[i];
sum_xx+= xx[i];
sum_yy+=yy[i];
sum_xy+= x[i]*y[i];
}
nr=(n*sum_xy)-(sum_x*sum_y);
float sum_x2=sum_x*sum_x;
float sum_y2=sum_y*sum_y;
dr_1=(n*sum_xx)-sum_x2;
dr_2=(n*sum_yy)-sum_y2;
dr_3=dr_1*dr_2;
dr=sqrt(dr_3);
r=(nr/dr);
printf("Total Numbers:%d Correlation Coefficient:%.2f",n,r);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote