Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Sunday, April 4, 2010

To find and print Karl pearson's correlation coefficient.

Walk A Mile In My ShoesWrite 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]
Need You Now
The Story So Far

#include<stdio.h>
#include<conio.h>
#include<math.h>
#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);


}

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP