To find and print Correlation of coefficient.
The Blind SideWrite a program in C to input 5 integer values of x & y and to calculate and print the coefficient of correlation between x & y.
#include< #include< #include< void main( ) { int x, y, i; float sx=0, sy=0, sxx=0, syy=0, sxy=0, a, b, c, r; clrscr( ); for(i=1; i<=5; i++) { printf("Input values of x and y pairwise\n"); scanf("%d %d", &x, &y); sx = sx + x; sy = sy + y; sxx = sxx + x * x; syy = syy + y * y; } a = sxy - (sx * sy) / 5; b = sqrt(sxx - (sx * sx) / 5 ); c = sqrt(syy - (sy * sy) / 5 ); r = a / (b *c); printf("The correlation coefficient = %f\n", r); } |
---|
0 comments:
Post a Comment