DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T c

⟦38da0f01b⟧ TextFile

    Length: 518 (0x206)
    Types: TextFile
    Names: »cor.c«

Derivation

└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
    └─ ⟦this⟧ »cph85dist/stat/src/cor.c« 

TextFile

/*LINTLIBRARY*/
#include "unixstat.h"
FUN(cor,correlation coefficient,5.0,1985)

double
cor (x,y,n)
float *x, *y;
	{
	double sumx = 0.0;
	double sumy = 0.0;
	double ssx = 0.0;
	double ssy = 0.0;
	double sumxy = 0.0;
	double denom, r;
	extern double sqrt ();
	int	i;
	for (i = 0; i < n; i++)
		{
		sumx += *x;
		sumy += *y;
		ssx  += *x * *x;
		ssy  += *y * *y;
		sumxy+= *x++ * *y++;
		}
	if ((denom = (n*ssx-sumx*sumx)*(n*ssy-sumy*sumy)) < FZERO)
		return (0.0);
	r = (n*sumxy-sumx*sumy)/sqrt(denom);
	return (r);
	}