To find and print Karl pearson's correlation coefficient.
Walk A Mile In My Shoes
Write a program in C to input 10 pairs of x and y values and then print Karl pearson's correlation coefficient.
It Didn't Make A Sound [+Video]


The Story So Far
It Didn't Make A Sound [+Video]
The Story So Far
#include< #include< #include< #define N 10 void main( ) { int i; float x, y, sx=0, sy=0, sxx=0, syy=0, sxy=0, a, b, c, r; for(i=0; i { printf("Enter values for x & y"); scanf("%f %f", &x, &y); sx = sx + x; sy = sy + y; sxx = sxx + x * x; syy = syy + y * y; sxy = sxy + x * y; } a = sxy-sx*sy/N; b = sqrt(sxx-sx*sx/N); c = sqrt(syy-sy*sy/N); r = a / (b*c); printf("Coefficient of correlation is %f\n", r); } |
---|
0 comments:
Post a Comment