/* Does a one-sample t-test of H_0: \mu=c, using IMSL The default value of c is 0, but it can also be specified on the command line */ /* gcc -O2 -o ttest.exe ttest.c -limsl -lfor -lUfor -lm */ #include #include #include #define N 10 extern double dtdf_(); int main(int argc, char *argv[]) { FILE *fp; int i,j; double data[N]; double mu=0; /* null hyp. mean -- can be read in; default=0 */ double mean, sd, t, df; sd = mean = 0; fp = fopen("sortvec1.dat","r"); for(i=0;i1) mu = atof(argv[1]); df = N-1.0; t = (mean - mu)/(sd/sqrt(N)); printf("Mean = %g \t Std Dev = %g\n",mean,sd); printf("t = %g on %g df\n",t,df); t = fabs(t); printf("p-value = %g\n\n", 2.0*(1-dtdf_(&t, &df)) ); } /* in Splus: sortvec1_scan("sortvec1.dat") t.test(sortvec1) */ /* Fits a linear regression using the IMSL routine DRGIVN */ /* gcc -O2 -o linreg.exe linreg.c -limsl -lfor -lUfor -lm setenv LM_LICENSE_FILE "/usr/pkg/matlab/etc/license.dat" gcc -O2 -o linreg.exe linreg.c -L/usr/local/lib/ -lsocket -lnsl -limsl -L/usr/pkg/spro/sun4m_55/lib/ -lF77 -lM77 -lsunmath -lm */ #include #include #include #define N 30 #define P 5 /* P is the number of independent variables */ int main(int argc, char *argv[]) { FILE *fp; int i,j; double tdata[P+1][N]; /* transpose of data */ int n=N; /* number of cases */ double bhat[P+1]; /* fitted coefficients */ double r[P+1][P+1]; /* R from QR of regression */ double tol=1.0e-8; /* lots of stuff for IMSL */ int zero=0,one=1,minusone=-1; int ncol=P+1,iind=-P; double d[P+1],xmin[P+1],xmax[P+1]; int irank,nrmiss; /* rank of R, # missing obsv */ double dfe,scpe; /* df for SSE, SSE */ fp = fopen("oxide.nh.dat","r"); for(i=0;i #include #define N 7 extern void dsyev_(); int main(int argc, char *argv[]) { int i,j; double matrix[N][N]; double matcopy[N][N]; double eigen[N]; char jobz[2]="N",uplo[2]="U"; int n=N, lwork=3*N; int info; double work[3*N]; for(i=0;i