add numerical recipes library
This commit is contained in:
21
lib/nr/k_and_r/recipes/tptest.c
Normal file
21
lib/nr/k_and_r/recipes/tptest.c
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
void tptest(data1,data2,n,t,prob)
|
||||
float *prob,*t,data1[],data2[];
|
||||
unsigned long n;
|
||||
{
|
||||
float betai();
|
||||
void avevar();
|
||||
unsigned long j;
|
||||
float var1,var2,ave1,ave2,sd,df,cov=0.0;
|
||||
|
||||
avevar(data1,n,&ave1,&var1);
|
||||
avevar(data2,n,&ave2,&var2);
|
||||
for (j=1;j<=n;j++)
|
||||
cov += (data1[j]-ave1)*(data2[j]-ave2);
|
||||
cov /= df=n-1;
|
||||
sd=sqrt((var1+var2-2.0*cov)/n);
|
||||
*t=(ave1-ave2)/sd;
|
||||
*prob=betai(0.5*df,0.5,df/(df+(*t)*(*t)));
|
||||
}
|
||||
Reference in New Issue
Block a user