void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [Options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to be used [default whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [default 0]\n"); fprintf(stderr,"\t-c column [default 1,...,# of components]\n"); fprintf(stderr,"\t-m #of components,embedding dimension [default 1,2]\n"); fprintf(stderr,"\t-d delay for the embedding [default 1]\n"); fprintf(stderr,"\t-L # of iterations [default 1000]\n"); fprintf(stderr,"\t-k # of neighbors [default %u]\n",MINN); fprintf(stderr,"\t-K fix # of neighbors [default no]\n"); fprintf(stderr,"\t-%% # variance of noise [default %3.1lf]\n",Q); fprintf(stderr,"\t-I seed for the rnd-generator (If seed=0, the time\n" "\t\tcommand is used to set the seed) [Default: fixed]\n"); fprintf(stderr,"\t-r size of initial neighborhood [" " default (data interval)/1000]\n"); fprintf(stderr,"\t-f factor to increase size [default 1.2]\n"); fprintf(stderr,"\t-o output file [default 'datafile'.lzr;" " no -o means write to stdout]\n"); fprintf(stderr,"\t-V verbosity level [default 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to use [Default: whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignore [Default: 0]\n"); fprintf(stderr,"\t-c columns to read [Default: 2]\n"); fprintf(stderr,"\t-m columns,embedding dim. to use [Default: 2,1]\n"); fprintf(stderr,"\t-d delay to use [Default: 1]\n"); fprintf(stderr,"\t-q projection dimension [Default: no projection]\n"); fprintf(stderr,"\t-W # what to write: [Default: 0]\n" "\t\t0 write eigenvalues only\n" "\t\t1 write eigenvectors\n" "\t\t2 write (projected) pca components\n" "\t\t3 write projected data\n"); fprintf(stderr,"\t-o output file name \n\t\t[Default: stdout; -o without " "value means 'datafile'.pca]\n"); fprintf(stderr,"\t-V verbosity level [Default: 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to use [default: whole file]\n"); fprintf(stderr,"\t-x # of lines to ignore [default: 0]\n"); fprintf(stderr,"\t-m # of components to be read [default: %u]\n",dim); fprintf(stderr,"\t-c columns to read [default: 1,...,# of components]\n"); fprintf(stderr,"\t-z minimum of the new series [default: 0.0]\n"); fprintf(stderr,"\t-Z maximum of the new series [default: 1.0]\n"); fprintf(stderr,"\t-a create a series with average value equals 0\n"); fprintf(stderr,"\t-v create a series with variance 1\n"); fprintf(stderr,"\t-u use unbiased estimator for variance (divide by N-1)\n"); fprintf(stderr,"\t-o output file name [default: 'datafile'.res']\n"); fprintf(stderr,"\t-V verbosity level [default: 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr,"Usage: %s [options]\n",progname); fprintf(stderr,"Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to use [Default: whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [Default: 0]\n"); fprintf(stderr,"\t-c columns to read [Default: 1]\n"); fprintf(stderr,"\t-m # of components,embedding dimension [Default: 1,2]\n"); fprintf(stderr,"\t-d delay [Default: 1]\n"); fprintf(stderr,"\t-r size of the neighbourhood " "[Default: (data interval)/1000]\n"); fprintf(stderr,"\t-%% print only a percentage of points found [Default: " " 100.0]\n"); fprintf(stderr,"\t-o output file name [Default: 'datafile'.rec\n" "\t\twithout -o: stdout]\n"); fprintf(stderr,"\t-V verbosity level [Default: 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
int main(int argc,char **argv) { long i; char stdi=0; double min,max,maxmax; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".rec"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.rec"); } } if (!stdo) test_outfile(outfile); if (columns == NULL) series=(double**)get_multi_series(infile,&length,exclude,&dim,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&length,exclude,&dim,columns, dimset,verbosity); maxmax=0.0; for (i=0;i<dim;i++) { rescale_data(series[i],length,&min,&max); if (max > maxmax) maxmax=max; } if (epsset) eps /= maxmax; check_alloc(list=(long*)malloc(sizeof(long)*length)); check_alloc(box=(long**)malloc(sizeof(long*)*BOX)); for (i=0;i<BOX;i++) check_alloc(box[i]=(long*)malloc(sizeof(long)*BOX)); make_multi_box(series,box,list,length,BOX,dim,embed,delay,eps); lfind_neighbors(); return 0; }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of datapoints [default is whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [default is 0]\n"); fprintf(stderr,"\t-c column to read[default 1]\n"); fprintf(stderr,"\t-m embedding dimension [default 2]\n"); fprintf(stderr,"\t-d delay [default 1]\n"); fprintf(stderr,"\t-t time window to omit [default 0]\n"); fprintf(stderr,"\t-r epsilon size to start with [default " "(data interval)/1000]\n"); fprintf(stderr,"\t-s # of iterations [default 10]\n"); fprintf(stderr,"\t-o name of output file [default 'datafile'.ros]\n"); fprintf(stderr,"\t-V verbosity level [default 3]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n\t\t" "2='+ give more detailed information about the length scales\n"); fprintf(stderr,"\t-h show these options\n"); fprintf(stderr,"\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [Options]\n\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of points to be used [Default: whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [Default: %lu]\n",exclude); fprintf(stderr,"\t-m # of columns to read [Default: %u]\n",dim); fprintf(stderr,"\t-c column(s) to read [Default: 1]\n"); fprintf(stderr,"\t-%% noiselevel in %% [Default: %.1e%%]\n", noiselevel*100.0); fprintf(stderr,"\t-r absolute noise level (or absolute variance in case\n" "\t\tof gaussian noise) [Default: not set]\n"); fprintf(stderr,"\t-g (use gaussian noise) [Default: uniform]\n"); fprintf(stderr,"\t-I seed for the rnd-generator (If seed=0, the time\n" "\t\tcommand is used to set the seed) [Default: fixed]\n"); fprintf(stderr,"\t-0 do not read input, just generate random numbers\n\t\t" "(needs -l and -r) [Default: not set]\n"); fprintf(stderr,"\t-o outfile [Without argument 'datafile'.noi;" " Without -o stdout is used]\n"); fprintf(stderr,"\t-V verbosity level [Default: 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr," -h show these options"); fprintf(stderr,"\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [Options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to be used [default whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [default 0]\n"); fprintf(stderr,"\t-c column [default 1,...,# of components]\n"); fprintf(stderr,"\t-m #of components,embedding dimension [default 1,2]\n"); fprintf(stderr,"\t-d delay for the embedding [default 1]\n"); fprintf(stderr,"\t-L # of iterations [default 1000]\n"); fprintf(stderr,"\t-k # of neighbors [default 30]\n"); fprintf(stderr,"\t-r size of initial neighborhood [" " default (data interval)/1000]\n"); fprintf(stderr,"\t-f factor to increase size [default 1.2]\n"); fprintf(stderr,"\t-0 perfom a zeroth order fit [default not set]\n"); fprintf(stderr,"\t-o output file [default 'datafile'.cast;" " no -o means write to stdout]\n"); fprintf(stderr,"\t-V verbosity level [default 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data [default: whole file]\n"); fprintf(stderr,"\t-x # of lines to ignore [default: 0]\n"); fprintf(stderr,"\t-c columns to read [default: 1]\n"); fprintf(stderr,"\t-m min. test embedding dimension [default: %u]\n",minemb); fprintf(stderr,"\t-M # of components,max. emb. dim. [default: %u,%u]\n", comp,maxemb); fprintf(stderr,"\t-d delay [default: 1]\n"); fprintf(stderr,"\t-f escape factor [default: %.2lf]\n",rt); fprintf(stderr,"\t-t theiler window [default: 0]\n"); fprintf(stderr,"\t-o output file [default: 'datafile'.fnn; without -o" " stdout]\n"); fprintf(stderr,"\t-V verbosity level [default: 3]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n\t\t" "2='+ information about the current state\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
int main(int argc,char **argv) { char stdi=0; unsigned int i,j; double rms,*av; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".pca"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.pca"); } } if (!stout) test_outfile(outfile); if (column == NULL) series=(double**)get_multi_series(infile,&LENGTH,exclude,&DIM,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&LENGTH,exclude,&DIM,column, dimset,verbosity); dimemb=DIM*EMB; if (!projection_set) LDIM=dimemb; else { if (LDIM < 1) LDIM=1; if (LDIM > dimemb) LDIM=dimemb; } check_alloc(av=(double*)malloc(sizeof(double)*DIM)); for (j=0;j<DIM;j++) { av[j]=rms=0.0; variance(series[j],LENGTH,&av[j],&rms); for (i=0;i<LENGTH;i++) series[j][i] -= av[j]; } make_pca(av); return 0; }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [options]\n",progname); fprintf(stderr," options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted as a" " possible datafile.\nIf no datafile is given stdin is read. " " Just - also means stdin\n"); fprintf(stderr,"\t-l length of file [default whole file]\n"); fprintf(stderr,"\t-x # of lines to ignore [default %ld]\n",exclude); fprintf(stderr,"\t-c column to read [default %d]\n",column); fprintf(stderr,"\t-b # of intervals [default %ld]\n",base); fprintf(stderr,"\t-o output file [default 'datafile'.dat ;" " If no -o is given: stdout]\n"); fprintf(stderr,"\t-V verbosity level [default 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [Options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l length [default is whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [default 0]\n"); fprintf(stderr,"\t-c which columns (separated by commas) [default is 1,2]\n"); fprintf(stderr,"\t-D corrlength [default is 100]\n"); fprintf(stderr,"\t-o output_file [default is 'datafile'.crc; no -o" " means stdout]\n"); fprintf(stderr,"\t-V verbosity level [default is 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-h show these options\n"); fprintf(stderr,"\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr,"\nUsage: %s [options]\n",progname); fprintf(stderr,"Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted as a" " possible datafile.\nIf no datafile is given stdin is read." " Just - also means stdin\n"); fprintf(stderr,"\t-l # of data [default: whole file]\n"); fprintf(stderr,"\t-x # of rows to ignore [default: 0]\n"); fprintf(stderr,"\t-M num. of columns to read [default: %u]\n",indim); fprintf(stderr,"\t-c columns to read [default: 1,...,M]\n"); fprintf(stderr,"\t-m dimension [default: 2]\n"); fprintf(stderr,"\t-F format of the delay vector (see man page)\n"); fprintf(stderr,"\t-d delay [default: 1]\n"); fprintf(stderr,"\t-D multi delay list (see man page)\n"); fprintf(stderr,"\t-V verbosity level [default: 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n"); fprintf(stderr,"\t-o output file [default: 'datafile'.del, " "without -o: stdout]\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); }
void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l length of file [default is whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [default is 0]\n"); fprintf(stderr,"\t-m dimension [default is 1]\n"); fprintf(stderr,"\t-c columns to read [default is 1,...,dimension]\n"); fprintf(stderr,"\t-p #order of AR-Fit [default is 1]\n"); fprintf(stderr,"\t-s length of iterated model [default no iteration]\n"); fprintf(stderr,"\t-o output file name [default is 'datafile'.ar]\n"); fprintf(stderr,"\t-V verbosity level [default is 1]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n\t\t" "2='+ print residuals though iterating a model'\n\t\t" "4='+ print original data plus residuals'\n"); fprintf(stderr,"\t-h show these options\n\n"); exit(0); }
int main(int argc,char **argv) { char stin=0; unsigned long i; int j,k; unsigned int alldim,maxemb,emb,rundel,delsum,runmdel; unsigned int *inddelay; FILE *fout; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stin=1; if (outfile == NULL) { if (!stin) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,1)); strcpy(outfile,infile); strcat(outfile,".del"); } else { check_alloc(outfile=(char*)calloc(10,1)); strcpy(outfile,"stdin.del"); } } if (!stdo) test_outfile(outfile); if (delayset && mdelayset) { fprintf(stderr,"-d and -D can't be used simultaneously. Exiting!\n"); exit(DELAY_INCONS_d_D); } if (delay < 1) { fprintf(stderr,"Delay has to be larger than 0. Exiting!\n"); exit(DELAY_SMALL_ZERO); } if (!formatset && (embdim%indim)) { fprintf(stderr,"Inconsistent -m and -M. Please set -F\n"); exit(DELAY_INCONS_m_M); } if (formatset) { create_format_list(); } else { check_alloc(formatlist=(unsigned int*)malloc(sizeof(int)*indim)); for (i=0;i<indim;i++) { formatlist[i]=embdim/indim; } } alldim=0; for (i=0;i<indim;i++) alldim += formatlist[i]; if (mdelayset) { create_delay_list(); } check_alloc(inddelay=(unsigned int*)malloc(sizeof(int)*alldim)); rundel=0; if (!mdelayset) { for (i=0;i<indim;i++) { delsum=0; inddelay[rundel++]=delsum; for (j=1;j<formatlist[i];j++) { delsum += delay; inddelay[rundel++]=delsum; } } } else { runmdel=0; for (i=0;i<indim;i++) { delsum=0; inddelay[rundel++]=delsum; for (j=1;j<formatlist[i];j++) { delsum += delaylist[runmdel++]; inddelay[rundel++]=delsum; } } } maxemb=0; for (i=0;i<alldim;i++) maxemb=(maxemb<inddelay[i])?inddelay[i]:maxemb; if (column == NULL) { series=get_multi_series(infile,&length,exclude,&indim,"",dimset,verbosity); } else { series=get_multi_series(infile,&length,exclude,&indim,column,dimset, verbosity); } if (stdo) { if (verbosity) fprintf(stderr,"Writing to stdout\n"); for (i=maxemb;i<length;i++) { rundel=0; for (j=0;j<indim;j++) { emb=formatlist[j]; for (k=0;k<emb;k++) fprintf(stdout,"%e ",series[j][i-inddelay[rundel++]]); } fprintf(stdout,"\n"); } } else { fout=fopen(outfile,"w"); if (verbosity) fprintf(stderr,"Opened %s for writing\n",outfile); for (i=maxemb;i<length;i++) { for (j=0;j<indim;j++) { rundel=0; emb=formatlist[j]; for (k=0;k<emb;k++) fprintf(fout,"%e ",series[j][i-inddelay[rundel++]]); } fprintf(fout,"\n"); } fclose(fout); } if (formatlist != NULL) free(formatlist); if (delaylist != NULL) free(delaylist); free(inddelay); return 0; }
int main(int argc,char** argv) { char stdi=0; long i; unsigned int dummy=2; FILE *fout=NULL; double **both; double av1,var1,av2,var2; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,0L,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".ccr"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.ccr"); } } if (!stout) test_outfile(outfile); if (columns == NULL) both=(double**)get_multi_series(infile,&length,exclude,&dummy,"",(char)1, verbosity); else both=(double**)get_multi_series(infile,&length,exclude,&dummy,columns, (char)1,verbosity); array1=both[0]; array2=both[1]; if (tau >= length) tau=length-1; variance(array1,length,&av1,&var1); variance(array2,length,&av2,&var2); for (i=0;i<length;i++) { array1[i] -= av1; array2[i] -= av2; } if (!stout) { fout=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); fprintf(fout,"# average of first comp.=%e\n",av1); fprintf(fout,"# standard deviation of first comp.=%e\n",var1); fprintf(fout,"# average of sec. comp.=%e\n",av2); fprintf(fout,"# standard deviation of sec. comp.=%e\n",var2); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); fprintf(stdout,"# average of first comp.=%e\n",av1); fprintf(stdout,"# standard deviation of first comp.=%e\n",var1); fprintf(stdout,"# average of sec. comp.=%e\n",av2); fprintf(stdout,"# standard deviation of sec. comp.=%e\n",var2); } for (i= -tau;i<=tau;i++) if (!stout) { fprintf(fout,"%ld %e\n",i,corr(i)/var1/var2); fflush(fout); } else { fprintf(stdout,"%ld %e\n",i,corr(i)/var1/var2); fflush(stdout); } if (!stout) fclose(fout); return 0; }
int main(int argc,char** argv) { char stdi=0; unsigned long i,j; double av=0.0,*sigmax; FILE *fout; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif if (!justcreate) { infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; } else stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".noi"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.noi"); } } if (!stout) test_outfile(outfile); if (!justcreate) { if (column == NULL) array=(double**)get_multi_series(infile,&length,exclude,&dim,"",dimset, verbosity); else array=(double**)get_multi_series(infile,&length,exclude,&dim,column, dimset,verbosity); } else { check_alloc(array=(double**)malloc(sizeof(double*)*dim)); for (i=0;i<dim;i++) { check_alloc(array[i]=(double*)malloc(sizeof(double)*length)); for (j=0;j<length;j++) array[i][j]=0.0; } } check_alloc(sigmax=(double*)malloc(sizeof(double)*dim)); if (!absolute) { for (j=0;j<dim;j++) variance(array[j],length,&av,&sigmax[j]); } rnd_init(iseed); for (i=0;i<10000;i++) rnd_1279(); for (j=0;j<dim;j++) { if (!cgaussian) equidistri(sigmax[j],j); else gauss(sigmax[j],j); } if (!stout) { fout=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); for (i=0;i<length;i++) { for (j=0;j<dim-1;j++) fprintf(fout,"%e ",array[j][i]); fprintf(fout,"%e\n",array[dim-1][i]); } fclose(fout); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); for (i=0;i<length;i++) { for (j=0;j<dim-1;j++) fprintf(stdout,"%e ",array[j][i]); fprintf(stdout,"%e\n",array[dim-1][i]); } } for (i=0;i<dim;i++) free(array[i]); free(array); free(sigmax); if (outfile != NULL) free(outfile); if (infile != NULL) free(infile); if (column != NULL) free(column); return 0; }
int main(int argc,char **argv) { char stdi=0; double *pm; long i,j; FILE *file; double **mat,**inverse,*vec,**coeff,**diff,avpm; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+4,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".ar"); } else { check_alloc(outfile=(char*)calloc((size_t)9,(size_t)1)); strcpy(outfile,"stdin.ar"); } } if (!stdo) test_outfile(outfile); if (column == NULL) series=(double**)get_multi_series(infile,&length,exclude,&dim,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&length,exclude,&dim,column, dimset,verbosity); check_alloc(my_average=(double*)malloc(sizeof(double)*dim)); set_averages_to_zero(); if (poles >= length) { fprintf(stderr,"It makes no sense to have more poles than data! Exiting\n"); exit(AR_MODEL_TOO_MANY_POLES); } check_alloc(vec=(double*)malloc(sizeof(double)*poles*dim)); check_alloc(mat=(double**)malloc(sizeof(double*)*poles*dim)); for (i=0;i<poles*dim;i++) check_alloc(mat[i]=(double*)malloc(sizeof(double)*poles*dim)); check_alloc(coeff=(double**)malloc(sizeof(double*)*dim)); inverse=build_matrix(mat); for (i=0;i<dim;i++) { build_vector(vec,i); coeff[i]=multiply_matrix_vector(inverse,vec); } check_alloc(diff=(double**)malloc(sizeof(double*)*dim)); for (i=0;i<dim;i++) check_alloc(diff[i]=(double*)malloc(sizeof(double)*length)); pm=make_residuals(diff,coeff); if (stdo) { avpm=pm[0]*pm[0]; for (i=1;i<dim;i++) avpm += pm[i]*pm[i]; avpm=sqrt(avpm/dim); printf("#average forcast error= %e\n",avpm); printf("#individual forecast errors: "); for (i=0;i<dim;i++) printf("%e ",pm[i]); printf("\n"); for (i=0;i<dim*poles;i++) { printf("# "); for (j=0;j<dim;j++) printf("%e ",coeff[j][i]); printf("\n"); } if (!run_model || (verbosity&VER_USR1)) { for (i=poles;i<length;i++) { if (run_model) printf("#"); for (j=0;j<dim;j++) if (verbosity&VER_USR2) printf("%e %e ",series[j][i]+my_average[j],diff[j][i]); else printf("%e ",diff[j][i]); printf("\n"); } } if (run_model && (ilength > 0)) iterate_model(coeff,pm,NULL); } else { file=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for output\n",outfile); avpm=pm[0]*pm[0]; for (i=1;i<dim;i++) avpm += pm[i]*pm[i]; avpm=sqrt(avpm/dim); fprintf(file,"#average forcast error= %e\n",avpm); fprintf(file,"#individual forecast errors: "); for (i=0;i<dim;i++) fprintf(file,"%e ",pm[i]); fprintf(file,"\n"); for (i=0;i<dim*poles;i++) { fprintf(file,"# "); for (j=0;j<dim;j++) fprintf(file,"%e ",coeff[j][i]); fprintf(file,"\n"); } if (!run_model || (verbosity&VER_USR1)) { for (i=poles;i<length;i++) { if (run_model) fprintf(file,"#"); for (j=0;j<dim;j++) if (verbosity&VER_USR2) fprintf(file,"%e %e ",series[j][i]+my_average[j],diff[j][i]); else fprintf(file,"%e ",diff[j][i]); fprintf(file,"\n"); } } if (run_model && (ilength > 0)) iterate_model(coeff,pm,file); fclose(file); } if (outfile != NULL) free(outfile); if (infile != NULL) free(infile); free(vec); for (i=0;i<poles*dim;i++) { free(mat[i]); free(inverse[i]); } free(mat); free(inverse); for (i=0;i<dim;i++) { free(coeff[i]); free(diff[i]); } free(coeff); free(diff); free(pm); return 0; }
int main(int argc,char** argv) { char stdi=0; long i; FILE *fout=NULL; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,&column,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".cor"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.cor"); } } if (!stout) test_outfile(outfile); array=(double*)get_series(infile,&length,exclude,column,verbosity); if (tau >= length) tau=length-1; variance(array,length,&av,&var); if (normalize) { for (i=0;i<length;i++) array[i] -= av; } if (!stout) { fout=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); fprintf(fout,"# average=%e\n",av); fprintf(fout,"# standard deviation=%e\n",var); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); fprintf(stdout,"# average=%e\n",av); fprintf(stdout,"# standard deviation=%e\n",var); } if (normalize) var *= var; else var=1.0; for (i=0;i<=tau;i++) if (!stout) { fprintf(fout,"%ld %e\n",i,corr(i)/var); fflush(fout); } else { fprintf(stdout,"%ld %e\n",i,corr(i)/var); fflush(stdout); } if (!stout) fclose(fout); if (outfile != NULL) free(outfile); if (infile != NULL) free(infile); free(array); return 0; }
int main(int argc,char **argv) { char stdi=0,*done,alldone; int i; long n; long maxlength; double min,max; FILE *file; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,&column,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".ros"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.ros"); } } test_outfile(outfile); series=(double*)get_series(infile,&length,exclude,column,verbosity); rescale_data(series,length,&min,&max); if (epsset) eps0 /= max; check_alloc(list=(long*)malloc(length*sizeof(long))); check_alloc(lyap=(double*)malloc((steps+1)*sizeof(double))); check_alloc(found=(long*)malloc((steps+1)*sizeof(long))); check_alloc(done=(char*)malloc(length)); for (i=0;i<=steps;i++) { lyap[i]=0.0; found[i]=0; } for (i=0;i<length;i++) done[i]=0; maxlength=length-delay*(dim-1)-steps-1-mindist; alldone=0; file=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); for (eps=eps0;!alldone;eps*=1.1) { epsinv=1.0/eps; put_in_boxes(); alldone=1; for (n=0;n<=maxlength;n++) { if (!done[n]) done[n]=make_iterate(n); alldone &= done[n]; } if (verbosity&VER_USR1) fprintf(stderr,"epsilon: %e already found: %ld\n",eps*max,found[0]); } for (i=0;i<=steps;i++) if (found[i]) fprintf(file,"%d %e\n",i,lyap[i]/found[i]/2.0); fclose(file); return 0; }
int main(int argc,char **argv) { char stdi=0; FILE *file; double min,max; double av,varianz; long i,n; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".res"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.res"); } } if (!stdo) test_outfile(outfile); if (xmin >= xmax) { fprintf(stderr,"Choosing the minimum larger or equal the maximum\n" "makes no sense. Exiting!\n"); exit(RESCALE__WRONG_INTERVAL); } if (column == NULL) series=(double**)get_multi_series(infile,&length,exclude,&dim,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&length,exclude,&dim,column, dimset,verbosity); for (n=0;n<dim;n++) { variance(series[n],length,&av,&varianz); if (ddof!=0) varianz *= sqrt((double) length/(length-ddof)); if (set_av) for (i=0;i<length;i++) series[n][i] -= av; if (set_var) for (i=0;i<length;i++) series[n][i] /= varianz; if (!set_var && !set_av) { rescale_data(series[n],length,&min,&max); for (i=0;i<length;i++) series[n][i]=series[n][i]*(xmax-xmin)+xmin; } } if (stdo) { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); for (i=0;i<length;i++) { fprintf(stdout,"%e",series[0][i]); for (n=1;n<dim;n++) fprintf(stdout," %e",series[n][i]); fprintf(stdout,"\n"); } } else { file=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); for (i=0;i<length;i++) { fprintf(file,"%e",series[0][i]); for (n=1;n<dim;n++) fprintf(file," %e",series[n][i]); fprintf(file,"\n"); } fclose(file); } return 0; }
int main(int argc,char **argv) { char stdi=0; unsigned long i,j; double x,norm,size=1.0,size2=1.0; double min,max; double *series; double average,var; long *box; FILE *fout; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,&column,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,1)); strcpy(outfile,infile); strcat(outfile,".his"); } else { check_alloc(outfile=(char*)calloc((size_t)10,1)); strcpy(outfile,"stdin.his"); } } if (!my_stdout) test_outfile(outfile); series=(double*)get_series(infile,&length,exclude,column,verbosity); variance(series,length,&average,&var); min=max=series[0]; for (i=1;i<length;i++) { if (series[i] < min) min=series[i]; else if (series[i] > max) max=series[i]; } max -= min; for (i=0;i<length;i++) series[i]=(series[i]-min); if (base > 0) { check_alloc(box=(long*)malloc(sizeof(long)*base)); for (i=0;i<base;i++) box[i]=0; size=1./base; size2=(1.0-size/2.0)*max; for (i=0;i<length;i++) { if (series[i] > size2) series[i]=size2; j=(long)(series[i]*base/max); box[j]++; } } if (!density) norm=1.0/(double)length; else norm=1.0/(double)length*(double)base/max; if (!my_stdout) { fout=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); fprintf(fout,"#interval of data: [%e:%e]\n",min,max+min); fprintf(fout,"#average= %e\n",average); fprintf(fout,"#standard deviation= %e\n",var); for (i=0;i<base;i++) { x=(double)(i*size); fprintf(fout,"%e %e\n",(x+size/2.0)*max+min,(double)box[i]*norm); } fclose(fout); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); fprintf(stdout,"#interval of data: [%e:%e]\n",min,max+min); fprintf(stdout,"#average= %e\n",average); fprintf(stdout,"#standard deviation= %e\n",var); for (i=0;i<base;i++) { x=(double)(i*size); fprintf(stdout,"%e %e\n",(x+size/2.0)*max+min,(double)box[i]*norm); fflush(stdout); } } return 0; }
int main(int argc,char **argv) { char stdi=0,done; long i,j,hdim,actfound; double maxinterval,*swap,*newcast; FILE *file=NULL; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+6,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".cast"); } else { check_alloc(outfile=(char*)calloc((size_t)11,(size_t)1)); strcpy(outfile,"stdin.cast"); } } if (!onscreen) test_outfile(outfile); hdim=(embed-1)*DELAY+1; if (column == NULL) series=(double**)get_multi_series(infile,&LENGTH,exclude,&dim,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&LENGTH,exclude,&dim,column, dimset,verbosity); check_alloc(min=(double*)malloc(sizeof(double)*dim)); check_alloc(interval=(double*)malloc(sizeof(double)*dim)); dim1=dim-1; maxinterval=0.0; for (i=0;i<dim;i++) { rescale_data(series[i],LENGTH,&min[i],&interval[i]); if (interval[i] > maxinterval) maxinterval=interval[i]; } check_alloc(cast=(double**)malloc(sizeof(double*)*hdim)); for (i=0;i<hdim;i++) check_alloc(cast[i]=(double*)malloc(sizeof(double)*dim)); check_alloc(newcast=(double*)malloc(sizeof(double)*dim)); check_alloc(list=(long*)malloc(sizeof(long)*LENGTH)); check_alloc(found=(long*)malloc(sizeof(long)*LENGTH)); check_alloc(box=(long**)malloc(sizeof(long*)*NMAX)); for (i=0;i<NMAX;i++) check_alloc(box[i]=(long*)malloc(sizeof(long)*NMAX)); check_alloc(localav=(double*)malloc(sizeof(double)*dim*embed)); check_alloc(foreav=(double*)malloc(sizeof(double)*dim)); check_alloc(vec=(double*)malloc(sizeof(double)*dim*embed)); check_alloc(mat=(double**)malloc(sizeof(double*)*dim*embed)); for (i=0;i<dim*embed;i++) check_alloc(mat[i]=(double*)malloc(sizeof(double)*dim*embed)); if (epsset) EPS0 /= maxinterval; for (j=0;j<dim;j++) for (i=0;i<hdim;i++) cast[i][j]=series[j][LENGTH-hdim+i]; if (!onscreen) { file=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); } for (i=0;i<FLENGTH;i++) { done=0; epsilon=EPS0/EPSF; while (!done) { epsilon*=EPSF; put_in_boxes(); actfound=hfind_neighbors(); if (actfound >= MINN) { if (!do_zeroth) make_fit(actfound,newcast); else make_zeroth(actfound,newcast); if (onscreen) { for (j=0;j<dim-1;j++) printf("%e ",newcast[j]*interval[j]+min[j]); printf("%e\n",newcast[dim-1]*interval[dim-1]+min[dim-1]); fflush(stdout); } else { for (j=0;j<dim-1;j++) fprintf(file,"%e ",newcast[j]*interval[j]+min[j]); fprintf(file,"%e\n",newcast[dim-1]*interval[dim-1]+min[dim-1]); fflush(file); } done=1; for (j=0;j<dim;j++) { if ((newcast[j] > 2.0) || (newcast[j] < -1.0)) { fprintf(stderr,"Forecast failed. Escaping data region!\n"); exit(NSTEP__ESCAPE_REGION); } } swap=cast[0]; for (j=0;j<hdim-1;j++) cast[j]=cast[j+1]; cast[hdim-1]=swap; for (j=0;j<dim;j++) cast[hdim-1][j]=newcast[j]; } } } if (!onscreen) fclose(file); if (outfile != NULL) free(outfile); for (i=0;i<embed*dim;i++) free(mat[i]); free(mat); for (i=0;i<hdim;i++) free(cast[i]); free(cast); free(newcast); free(found); free(list); for (i=0;i<NMAX;i++) free(box[i]); free(box); free(vec); free(localav); free(foreav); free(min); free(interval); for (i=0;i<dim;i++) free(series[i]); free(series); return 0; }
int main(int argc,char **argv) { char stdi=0,done; long i,j,hdim,actfound; unsigned long count=1; double *swap,*newcast,maxinterval,*min,*interval,dummy,epsilon0; FILE *file=NULL; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".lzr"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.lzr"); } } if (!onscreen) test_outfile(outfile); hdim=(embed-1)*DELAY+1; if (column == NULL) series=(double**)get_multi_series(infile,&LENGTH,exclude,&dim,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&LENGTH,exclude,&dim,column, dimset,verbosity); dim1=dim-1; check_alloc(min=(double*)malloc(sizeof(double)*dim)); check_alloc(interval=(double*)malloc(sizeof(double)*dim)); check_alloc(var=(double*)malloc(sizeof(double)*dim)); maxinterval=0.0; for (i=0;i<dim;i++) { rescale_data(series[i],LENGTH,&min[i],&interval[i]); variance(series[i],LENGTH,&dummy,&var[i]); if (interval[i] > maxinterval) maxinterval=interval[i]; } if (epsset) EPS0 /= maxinterval; check_alloc(cast=(double**)malloc(sizeof(double*)*hdim)); for (i=0;i<hdim;i++) check_alloc(cast[i]=(double*)malloc(sizeof(double)*dim)); check_alloc(newcast=(double*)malloc(sizeof(double)*dim)); check_alloc(newav=(double*)malloc(sizeof(double)*dim)); check_alloc(list=(long*)malloc(sizeof(long)*LENGTH)); check_alloc(found=(long*)malloc(sizeof(long)*LENGTH)); check_alloc(abstand=(double*)malloc(sizeof(double)*LENGTH)); check_alloc(box=(long**)malloc(sizeof(long*)*NMAX)); for (i=0;i<NMAX;i++) check_alloc(box[i]=(long*)malloc(sizeof(long)*NMAX)); check_alloc(vec=(double*)malloc(sizeof(double)*dim)); check_alloc(hsum=(double*)malloc(sizeof(double)*dim)); check_alloc(mat=(double**)malloc(sizeof(double*)*dim)); for (i=0;i<dim;i++) { check_alloc(mat[i]=(double*)malloc(sizeof(double)*dim)); } for (j=0;j<dim;j++) for (i=0;i<hdim;i++) cast[i][j]=series[j][LENGTH-hdim+i]; indexes=make_multi_index(dim,embed,DELAY); if (!onscreen) { file=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); } rnd_init(seed); epsilon0=EPS0/EPSF; if (setnoise) Q /= 100.0; for (i=0;i<FLENGTH;i++) { done=0; if (setsort) epsilon= epsilon0/((double)count*EPSF); else epsilon=epsilon0; while (!done) { epsilon*=EPSF; put_in_boxes(); actfound=hfind_neighbors(); if (actfound >= MINN) { if (setsort) { epsilon0 += epsilon; count++; sort(actfound); actfound=MINN; } make_zeroth(actfound,newcast); if (onscreen) { for (j=0;j<dim-1;j++) printf("%e ",newcast[j]*interval[j]+min[j]); printf("%e\n",newcast[dim-1]*interval[dim-1]+min[dim-1]); fflush(stdout); } else { for (j=0;j<dim-1;j++) fprintf(file,"%e ",newcast[j]*interval[j]+min[j]); fprintf(file,"%e\n",newcast[dim-1]*interval[dim-1]+min[dim-1]); fflush(file); } done=1; swap=cast[0]; for (j=0;j<hdim-1;j++) cast[j]=cast[j+1]; cast[hdim-1]=swap; for (j=0;j<dim;j++) cast[hdim-1][j]=newcast[j]; } } } if (!onscreen) fclose(file); if (outfile != NULL) free(outfile); for (i=0;i<dim;i++) free(mat[i]); free(mat); for (i=0;i<hdim;i++) free(cast[i]); free(cast); free(newcast); free(found); free(list); for (i=0;i<NMAX;i++) free(box[i]); free(box); free(vec); free(newav); for (i=0;i<dim;i++) free(series[i]); free(series); return 0; }
int main(int argc,char **argv) { char stdi=0; FILE *file=NULL; double min,inter=0.0,ind_inter,epsilon,av,ind_var; char *nearest,alldone; long i; unsigned int dim,emb; unsigned long donesofar; if (scan_help(argc,argv)) show_options(argv[0]); scan_options(argc,argv); #ifndef OMIT_WHAT_I_DO if (verbosity&VER_INPUT) what_i_do(argv[0],WID_STR); #endif infile=search_datafile(argc,argv,NULL,verbosity); if (infile == NULL) stdi=1; if (outfile == NULL) { if (!stdi) { check_alloc(outfile=(char*)calloc(strlen(infile)+5,(size_t)1)); strcpy(outfile,infile); strcat(outfile,".fnn"); } else { check_alloc(outfile=(char*)calloc((size_t)10,(size_t)1)); strcpy(outfile,"stdin.fnn"); } } if (!stdo) test_outfile(outfile); if (column == NULL) series=(double**)get_multi_series(infile,&length,exclude,&comp,"",dimset, verbosity); else series=(double**)get_multi_series(infile,&length,exclude,&comp,column, dimset,verbosity); for (i=0;i<comp;i++) { rescale_data(series[i],length,&min,&ind_inter); variance(series[i],length,&av,&ind_var); if (i == 0) { varianz=ind_var; inter=ind_inter; } else { varianz=(varianz>ind_var)?ind_var:varianz; inter=(inter<ind_inter)?ind_inter:inter; } } check_alloc(list=(long*)malloc(sizeof(long)*length)); check_alloc(nearest=(char*)malloc(length)); check_alloc(box=(long**)malloc(sizeof(long*)*BOX)); for (i=0;i<BOX;i++) check_alloc(box[i]=(long*)malloc(sizeof(long)*BOX)); if (!stdo) { file=fopen(outfile,"w"); if (verbosity&VER_INPUT) fprintf(stderr,"Opened %s for writing\n",outfile); } else { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); } check_alloc(vcomp=(unsigned int*)malloc(sizeof(int)*(maxdim))); check_alloc(vemb=(unsigned int*)malloc(sizeof(int)*(maxdim))); for (i=0;i<maxdim;i++) { if (comp == 1) { vcomp[i]=0; vemb[i]=i; } else { vcomp[i]=i%comp; vemb[i]=(i/comp)*delay; } } for (emb=minemb;emb<=maxemb;emb++) { dim=emb*comp-1; epsilon=eps0; toolarge=0; alldone=0; donesofar=0; aveps=0.0; vareps=0.0; for (i=0;i<length;i++) nearest[i]=0; if (verbosity&VER_USR1) fprintf(stderr,"Start for dimension=%u\n",dim+1); while (!alldone && (epsilon < 2.*varianz/rt)) { alldone=1; mmb(vcomp[dim],vemb[dim],epsilon); for (i=0;i<length-maxemb*delay;i++) if (!nearest[i]) { nearest[i]=find_nearest(i,dim,epsilon); alldone &= nearest[i]; donesofar += (unsigned long)nearest[i]; } if (verbosity&VER_USR1) fprintf(stderr,"Found %lu up to epsilon=%e\n",donesofar,epsilon*inter); epsilon*=sqrt(2.0); if (!donesofar) eps0=epsilon; } if (donesofar == 0) { fprintf(stderr,"Not enough points found!\n"); exit(FALSE_NEAREST_NOT_ENOUGH_POINTS); } aveps *= (1./(double)donesofar); vareps *= (1./(double)donesofar); if (stdo) { fprintf(stdout,"%u %e %e %e\n",dim+1,(double)toolarge/(double)donesofar, aveps*inter,sqrt(vareps)*inter); fflush(stdout); } else { fprintf(file,"%u %e %e %e\n",dim+1,(double)toolarge/(double)donesofar, aveps*inter,sqrt(vareps)*inter); fflush(file); } } if (!stdo) fclose(file); if (infile != NULL) free(infile); if (outfile != NULL) free(outfile); free(series); free(list); free(nearest); for (i=0;i<BOX;i++) free(box[i]); free(box); return 0; }