GLYLIB  0.3.0b
get_autocorr_est_array.c
Go to the documentation of this file.
00001 #include <stats.h>
00002 #include <mylib.h>
00003 //#include "../inc/stats.h"
00004 //#include "../inc/mylib.h"
00005 
00006 /********* get_autocorr_est_array *********/
00007 //autocorr get_autocorr_est_array(statsarray S,meanvar M);
00008 autocorr get_autocorr_est_array(statsarray S,meanvar M){
00009 autocorr A;
00010 int k=0,j=0;
00011 double *Dmu;
00012 
00013 // initialize
00014 A.k=M.n;
00015 A.a=(double*)calloc((A.k),sizeof(double));
00016 Dmu=(double*)calloc(S.n,sizeof(double));
00017 
00018 for(j=0;j<S.n;j++){
00019         Dmu[j]=S.d[j]-M.m;
00020         }
00021 for(k=0;k<(A.k);k++){
00022         for (j=0;j<(A.k-k);j++){
00023                 A.a[k]+=Dmu[j+k]*Dmu[j];
00024                 }
00025         A.a[k]/=((A.k-k)*M.v); // assumes whole population or biased sample
00026         }
00027 free(Dmu);
00028 return A;
00029 }
 All Classes Files Functions Variables Typedefs Defines