/* * This file is part of TISEAN * * Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber * * TISEAN is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * TISEAN is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TISEAN; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /*Author: Rainer Hegger. Last modified Sep 5, 2004 */ #include #include #include #include #include #include #include "routines/tsa.h" #define WID_STR "Fits a polynomial to the data." char *outfile=NULL,stdo=1; char *parin=NULL,*infile=NULL; unsigned long length=ULONG_MAX,insample=ULONG_MAX,exclude=0; unsigned long plength=UINT_MAX; unsigned long step=1000; unsigned int column=1,dim=2,delay=1,down_to=1; unsigned int **order; unsigned int verbosity=0xff; double *series,*param; 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: %lu]\n",exclude); fprintf(stderr,"\t-c column to read [default: %u]\n",column); fprintf(stderr,"\t-m embedding dimension [default: %u]\n",dim); fprintf(stderr,"\t-d delay [default: %u]\n",delay); fprintf(stderr,"\t-n insample data [default: all]\n"); fprintf(stderr,"\t-L length of forecasted series [default: %lu]\n",step); fprintf(stderr,"\t-p name of parameter file [default: parameter.pol]\n"); fprintf(stderr,"\t-o output file name [default: 'datafile'.pbf]\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 scan_options(int n,char **in) { char *out; if ((out=check_option(in,n,'l','u')) != NULL) sscanf(out,"%lu",&length); if ((out=check_option(in,n,'x','u')) != NULL) sscanf(out,"%lu",&exclude); if ((out=check_option(in,n,'c','u')) != NULL) sscanf(out,"%u",&column); if ((out=check_option(in,n,'m','u')) != NULL) sscanf(out,"%u",&dim); if ((out=check_option(in,n,'d','u')) != NULL) sscanf(out,"%u",&delay); if ((out=check_option(in,n,'V','u')) != NULL) sscanf(out,"%u",&verbosity); if ((out=check_option(in,n,'n','u')) != NULL) sscanf(out,"%lu",&insample); if ((out=check_option(in,n,'L','u')) != NULL) sscanf(out,"%lu",&step); if ((out=check_option(in,n,'p','s')) != NULL) parin=out; if ((out=check_option(in,n,'o','o')) != NULL) { stdo=0; if (strlen(out) > 0) outfile=out; } } double polynom(unsigned long act,unsigned int which) { unsigned int i,j; double ret=1.0,h; for (i=0;i= length) { insample=length; oose=0; } check_alloc(param=(double*)malloc(sizeof(double)*plength)); make_fit(); withalli=forecast_error(0LU,insample); withallo=0.0; if (oose) withallo=forecast_error(insample+1,length); if (stdo) { if (verbosity&VER_INPUT) fprintf(stderr,"Writing to stdout\n"); fprintf(stdout,"#FCE: %e %e\n",withalli/varianz,withallo/varianz); for (i=0;i