|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T v ┃
Length: 2681 (0xa79) Types: TextFile Names: »vincent.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─ ⟦this⟧ »cph85dist/stat/src/vincent.c«
#include "unixstat.h" PGM(vincent,Time Series Comparison,5.0,1985) /* Copyright (c) 1982 Gary Perlman (see Copyright file) */ /* vincentizing is a procedure in which an ordered list of numbers is divided into a chosen number of vincentiles and the average for each of these vincentiles is computed. Vincentizing is useful for comparing trends in data for which unequal sample sizes exist. This program takes its first argument as the number of tiles it is to divide the subsequent files' data into. vincent prints the number of numbers read in, the name of the file it read them from, and the means for each vincentile. This program was written by Gary Perlman in November of 1980. */ #define MAXPOINTS 5000 /* maximum number of points to store */ #define MAXTILES (MAXPOINTS/10) /* maximum number of tiles */ main (argc, argv) char **argv; { float store[MAXPOINTS]; /* stored data from each file */ double sum[MAXTILES]; /* sum of each n-tile */ int nfiles = argc-2; /* number of files */ int ntiles; /* number of vincentiles */ int file; /* loop variable */ FILE *ioptr, *fopen (); /* data read from file pointer */ int n; /* number of points from file */ register int i; /* loop variable */ char *filename; int usestdin = 0; /* can only use stdin once */ ARGV0; if (argc <= 2) USAGE (n-tiles file1 file2 ...) if (!INTEGER (argv[1])) ERRNUM (argv[1],number of tiles) if ((ntiles = atoi (argv[1])) < 1) ERRVAL (d,ntiles,number of tiles) if (ntiles > MAXTILES) ERRMANY (n-tiles, MAXTILES) for (file = 0; file < nfiles; file++) { filename = argv[file+2]; if (filename[0] == '-' && filename[1] == '\0') { if (usestdin) ERRMSG0 (You can only use the standard input '-' once) ioptr = stdin; checkstdin (Argv0); usestdin = 1; } else if ((ioptr = fopen (filename, "r")) == NULL) ERROPEN (filename) n = fgetf (ioptr, MAXPOINTS, store); printf ("%4d %-6s ", n, filename); if (n == 0) ERRDATA for (i = 0; i < ntiles; i++) sum[i] = 0.0; for (i = 0; i < n*ntiles; i++) sum[i/n] += store[i/ntiles]; for (i = 0; i < ntiles; i++) printf ("%12.4f ", sum[i]/n); putchar ('\n'); fclose (ioptr); } exit (0); } /* fgetf is a floating version of fgets */ fgetf (ioptr, maxx, array) FILE *ioptr; float *array; { register int i; char word[BUFSIZ]; double atof (); for (i = 0; getword (word, ioptr); i++) { if (i == maxx) ERRMANY (input values, maxx) if (!number (word)) ERRNUM (word,input value) else array[i] = atof (word); } return (i); }