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

⟦cbae54088⟧ TextFile

    Length: 550 (0x226)
    Types: TextFile
    Names: »cor.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/stat-5.3/eu/stat/src/cor.c« 

TextFile

/*  Copyright 1982 Gary Perlman */

/*LINTLIBRARY*/
#include "stat.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);
	}